Skip to content

Commit

Permalink
Dynamically places portals y-position dependant on the map floor
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAardvark committed Oct 10, 2021
1 parent 2873ded commit 3f56a59
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ private void spawnRobot() {

private void spawnPortal() {
GridPoint2 tileBounds = terrain.getMapBounds(0);
GridPoint2 pos1 = new GridPoint2(tileBounds.x - 2, 12);
int posY = terrainFactory.getYOfSurface(tileBounds.x - 2, GdxGame.ScreenType.MAIN_GAME);
GridPoint2 pos1 = new GridPoint2(tileBounds.x - 2, posY + 2);
this.endPortal = ObstacleFactory.createPortal();
spawnEntityAt(this.endPortal, pos1, true, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Vector2;
import com.deco2800.game.GdxGame;
import com.deco2800.game.areas.terrain.TerrainFactory;
import com.deco2800.game.areas.terrain.TerrainFactory.TerrainType;
import com.deco2800.game.components.CameraComponent;
Expand Down Expand Up @@ -355,6 +356,11 @@ private void spawnRobot() {

private void spawnPortal() {
GridPoint2 tileBounds = terrain.getMapBounds(0);

// Use this when text file is supplied
// int posY = terrainFactory.getYOfSurface(tileBounds.x - 2, GdxGame.ScreenType.LEVEL_THREE_GAME);
// GridPoint2 pos1 = new GridPoint2(tileBounds.x - 2, posY + 2);

GridPoint2 pos1 = new GridPoint2(tileBounds.x - 2, 12);
this.endPortal = ObstacleFactory.createPortal();
spawnEntityAt(this.endPortal, pos1, true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ private void spawnRobot() {

private void spawnPortal() {
GridPoint2 tileBounds = terrain.getMapBounds(0);
GridPoint2 pos1 = new GridPoint2(tileBounds.x - 2, 7);
int posY = terrainFactory.getYOfSurface(tileBounds.x - 2, GdxGame.ScreenType.LEVEL_TWO_GAME);
GridPoint2 pos1 = new GridPoint2(tileBounds.x - 2, posY + 2);
this.endPortal = ObstacleFactory.createPortal();
spawnEntityAt(this.endPortal, pos1, true, true);
}
Expand Down

0 comments on commit 3f56a59

Please sign in to comment.