mirror of
				https://github.com/inf112-v20/Fiasko.git
				synced 2025-10-30 17:23:45 +01:00 
			
		
		
		
	Legger til mulighet for å velge debuggingbrettet
Setter viewport på brettvisning til de faktiske dimensjonene til brettet Oppdaterer informasjon om debug knapp og spillstatus i README
This commit is contained in:
		| @@ -27,8 +27,8 @@ import java.util.List; | ||||
| public class BoardActiveScreen extends InteractiveScreen { | ||||
|     private final RoboRallyWrapper roboRallyWrapper; | ||||
|     private final int tileDimensions = 64; | ||||
|     private final int viewPortWidth = 12 * tileDimensions; | ||||
|     private final int viewPortHeight = 12 * tileDimensions; | ||||
|     private final int viewPortWidth; | ||||
|     private final int viewPortHeight; | ||||
|     private float cameraZoom = 1; | ||||
|     private int cameraX = 0; | ||||
|     private int cameraY = 0; | ||||
| @@ -42,6 +42,9 @@ public class BoardActiveScreen extends InteractiveScreen { | ||||
|     public BoardActiveScreen(final RoboRallyWrapper roboRallyWrapper) { | ||||
|         this.roboRallyWrapper = roboRallyWrapper; | ||||
|  | ||||
|         viewPortWidth = roboRallyWrapper.roboRallyGame.getWidth() * tileDimensions; | ||||
|         viewPortHeight = roboRallyWrapper.roboRallyGame.getHeight() * tileDimensions; | ||||
|  | ||||
|         camera.setToOrtho(false, viewPortWidth, viewPortHeight); | ||||
|         camera.position.set(viewPortWidth / 2f, viewPortHeight / 2f, 0); | ||||
|         viewport = new ExtendViewport(viewPortWidth, viewPortHeight, camera); | ||||
| @@ -139,7 +142,7 @@ public class BoardActiveScreen extends InteractiveScreen { | ||||
|     @Override | ||||
|     public boolean scrolled(int amount) { | ||||
|         if (amount < 0 && cameraZoom > 0.3 || amount > 0 && cameraZoom < 3) { | ||||
|             cameraZoom += 0.2 * amount; | ||||
|             cameraZoom += 0.1 * amount; | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
| @@ -150,8 +153,8 @@ public class BoardActiveScreen extends InteractiveScreen { | ||||
|     private void resetCamera() { | ||||
|         camera.up.x = 0; | ||||
|         camera.up.y = 1; | ||||
|         cameraZoom = 1.4f; | ||||
|         camera.position.set(viewPortWidth / 2f + 128, viewPortHeight / 2f + 128, 0); | ||||
|         cameraZoom = 1; | ||||
|         camera.position.set(viewPortWidth / 1.5f, viewPortHeight / 2f, 0); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -172,6 +175,7 @@ public class BoardActiveScreen extends InteractiveScreen { | ||||
|                     object.flipX(), object.flipY()); | ||||
|         } | ||||
|         int index = 1; | ||||
|         //Draws all participating players to the right of the board | ||||
|         for (Player player : roboRallyWrapper.roboRallyGame.getPlayers()) { | ||||
|             String playerName = player.getName(); | ||||
|             Robot robot = getPlayersRobot(player.getRobotID()); | ||||
| @@ -179,20 +183,22 @@ public class BoardActiveScreen extends InteractiveScreen { | ||||
|                 throw new IllegalArgumentException("The robot belonging to player " + playerName + | ||||
|                         " does not exist on the board."); | ||||
|             } | ||||
|             roboRallyWrapper.font.draw(batch, playerName, viewPortWidth, 128 * index); | ||||
|             roboRallyWrapper.font.getData().setScale(tileDimensions / 44); | ||||
|             roboRallyWrapper.font.draw(batch, playerName, viewPortWidth, 2 * tileDimensions * index); | ||||
|             roboRallyWrapper.font.draw(batch, "DMG: " + robot.getDamageTaken() + " LV: " + robot.getAmountOfLives(), | ||||
|                     viewPortWidth, 96 + 128 * (index - 1)); | ||||
|                     viewPortWidth, 1.5f * tileDimensions + 2 * tileDimensions * (index - 1)); | ||||
|             int lastFlagVisited = robot.getLastFlagVisited(); | ||||
|             if (lastFlagVisited > 0) { | ||||
|                 TileType flagType = TileType.getTileTypeFromID(robot.getLastFlagVisited() + 16); | ||||
|                 TextureRegion flagRegion = TextureConverterUtil.convertElement(new Tile(flagType, Direction.NORTH)); | ||||
|                 batch.draw(flagRegion.getTexture(), viewPortWidth + 64, 128 * (index - 1), 64 / 2, | ||||
|                         64 / 2, 64, 64, 1, 1, 0, flagRegion.getRegionX(), | ||||
|                 batch.draw(flagRegion.getTexture(), viewPortWidth + tileDimensions, 2 * tileDimensions * | ||||
|                                 (index - 1), tileDimensions / 2, tileDimensions / 2, tileDimensions, | ||||
|                         tileDimensions, 1, 1, 0, flagRegion.getRegionX(), | ||||
|                         flagRegion.getRegionY(), flagRegion.getRegionWidth(), flagRegion.getRegionWidth(), | ||||
|                         false, false); | ||||
|             } | ||||
|             TextureRegion robotTexture = TextureConverterUtil.convertElement(player.getRobotID()); | ||||
|             batch.draw(robotTexture, viewPortWidth, 128 * (index - 1)); | ||||
|             batch.draw(robotTexture, viewPortWidth, 2 * tileDimensions * (index - 1), tileDimensions, tileDimensions); | ||||
|             index++; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -1,12 +1,14 @@ | ||||
| package inf112.fiasko.roborally.gamewrapper.screens; | ||||
|  | ||||
| import com.badlogic.gdx.Gdx; | ||||
| import com.badlogic.gdx.Input; | ||||
| import com.badlogic.gdx.scenes.scene2d.InputEvent; | ||||
| import com.badlogic.gdx.scenes.scene2d.ui.Dialog; | ||||
| import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; | ||||
| import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||||
| import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | ||||
| import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; | ||||
| import com.badlogic.gdx.utils.Array; | ||||
| import com.badlogic.gdx.utils.viewport.FitViewport; | ||||
| import inf112.fiasko.roborally.gamewrapper.RoboRallyWrapper; | ||||
| import inf112.fiasko.roborally.gamewrapper.SimpleButton; | ||||
| @@ -21,8 +23,9 @@ import java.util.Map; | ||||
| /** | ||||
|  * This screen allows the host to wait for players to join | ||||
|  */ | ||||
| public class LobbyScreen extends AbstractScreen { | ||||
| public class LobbyScreen extends InteractiveScreen { | ||||
|     private final RoboRallyWrapper roboRallyWrapper; | ||||
|     final SelectBox<String> selectBox; | ||||
|  | ||||
|     /** | ||||
|      * Instantiates a new lobby screen | ||||
| @@ -43,7 +46,7 @@ public class LobbyScreen extends AbstractScreen { | ||||
|  | ||||
|         Dialog dialog = new Dialog("Setting", skin); | ||||
|  | ||||
|         final SelectBox<String> selectBox = new SelectBox<>(skin); | ||||
|         selectBox = new SelectBox<>(skin); | ||||
|         selectBox.setItems("Dizzy_Dash", "Checkmate", "Risky_Exchange"); | ||||
|         selectBox.setPosition(Gdx.graphics.getWidth() / 2f - 100, Gdx.graphics.getHeight() / 2f - 100); | ||||
|         selectBox.setSize(200, 50); | ||||
| @@ -76,6 +79,27 @@ public class LobbyScreen extends AbstractScreen { | ||||
|         stage.setViewport(viewport); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void show() { | ||||
|         super.show(); | ||||
|         inputMultiplexer.addProcessor(this); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean keyUp(int keyCode) { | ||||
|         if (keyCode == Input.Keys.HOME) { | ||||
|             Array<String> items = selectBox.getItems(); | ||||
|             String testBoard = "all_tiles_test_board"; | ||||
|             if (!items.contains(testBoard, true)) { | ||||
|                 items.add(testBoard); | ||||
|                 selectBox.setItems(items); | ||||
|                 selectBox.setSelected(testBoard); | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void render(float delta) { | ||||
|         super.render(delta); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user