mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-25 10:44:42 +02:00
Opprydding av ubrukte klasser og metoder
Fjerner Action.java Endrer Checkmate.txt tilbake til det offisielle brettet Endrer Game til å bevege roboten framover i stedet for en spesifikk retning Fjerner konseptet om døde roboter i Board Fjerner interface for kort Fjerner metoder for å sjekke om vegger og roboter har roterte teksturer Fjerner utkommentert testkode av tekst input Endrer litt testkode slik at alle roboter er brukt i koden
This commit is contained in:
@ -38,8 +38,6 @@ public class GameLauncher extends ApplicationAdapter {
|
||||
camera.setToOrtho(false, game.getWidth() * tileDimensions,
|
||||
game.getHeight() * tileDimensions);
|
||||
batch = new SpriteBatch();
|
||||
/*MyTextInputListener listener = new MyTextInputListener();
|
||||
Gdx.input.getTextInput(listener, "Input name", "", "Name");*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,15 +69,4 @@ public class GameLauncher extends ApplicationAdapter {
|
||||
textureSheet.dispose();
|
||||
batch.dispose();
|
||||
}
|
||||
|
||||
/*public static class MyTextInputListener implements Input.TextInputListener {
|
||||
@Override
|
||||
public void input (String text) {
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void canceled () {
|
||||
}
|
||||
}*/
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
/**
|
||||
* This enum represents an action on a programming card
|
||||
*/
|
||||
public enum Action {
|
||||
ROTATE_RIGHT,
|
||||
ROTATE_LEFT,
|
||||
U_TURN,
|
||||
MOVE_1,
|
||||
MOVE_2,
|
||||
MOVE_3,
|
||||
BACK_UP
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package inf112.fiasko.roborally.game;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Direction;
|
||||
import inf112.fiasko.roborally.element_properties.Position;
|
||||
import inf112.fiasko.roborally.element_properties.RobotID;
|
||||
import inf112.fiasko.roborally.objects.Board;
|
||||
@ -47,29 +46,40 @@ public class Game implements IDrawableGame {
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.SOUTH);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.rotateRobotLeft(RobotID.ROBOT_1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.EAST);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.EAST);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.SOUTH);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.EAST);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.WEST);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.EAST);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.EAST);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.WEST);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.WEST);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,6 @@ public class Board {
|
||||
private IGrid<Wall> walls;
|
||||
private IGrid<Tile> tiles;
|
||||
private Map<RobotID, Robot> robots;
|
||||
private List<Robot> deadRobots;
|
||||
|
||||
/**
|
||||
* Initializes the board
|
||||
@ -38,7 +37,6 @@ public class Board {
|
||||
}
|
||||
this.robots.put(robot.getRobotId(), robot);
|
||||
}
|
||||
this.deadRobots = new ArrayList<>();
|
||||
this.boardWidth = tiles.getWidth();
|
||||
this.boardHeight = tiles.getHeight();
|
||||
this.walls = walls;
|
||||
@ -61,18 +59,6 @@ public class Board {
|
||||
return boardWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves all dead robots to their backups and makes them part of the board again
|
||||
*/
|
||||
public void respawnRobots() {
|
||||
for (Robot robot : deadRobots) {
|
||||
robot.setPosition(robot.getBackupPosition());
|
||||
robot.setFacingDirection(Direction.NORTH);
|
||||
robots.put(robot.getRobotId(), robot);
|
||||
}
|
||||
deadRobots = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all alive robots from the board
|
||||
* @return A list of alive robots
|
||||
@ -103,7 +89,6 @@ public class Board {
|
||||
*/
|
||||
public void removeDeadRobotFromBoard(Robot robot) {
|
||||
robots.remove(robot.getRobotId());
|
||||
deadRobots.add(robot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,6 +111,14 @@ public class Board {
|
||||
robot.setFacingDirection(newDirection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a robot one unit forward according to the direction it's currently facing
|
||||
* @param robotID The robot to move
|
||||
*/
|
||||
public void moveRobotForward(RobotID robotID) {
|
||||
moveRobot(robotID, robots.get(robotID).getFacingDirection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a robot one unit in a specified direction
|
||||
* @param robotID ID of the robot to move
|
||||
|
@ -1,20 +0,0 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
/**
|
||||
* This Interface describes a card without a card suit
|
||||
* @param <S> The value type
|
||||
* @param <T> The symbol type
|
||||
*/
|
||||
public interface ICardWithoutSuit<S,T> {
|
||||
/**
|
||||
* Gets the value of the card
|
||||
* @return The card value
|
||||
*/
|
||||
S getValue();
|
||||
|
||||
/**
|
||||
* Gets the symbol of the card
|
||||
* @return The card symbol
|
||||
*/
|
||||
T getSymbol();
|
||||
}
|
@ -108,7 +108,7 @@ public final class IOUtil {
|
||||
Direction direction;
|
||||
if (element.getClass().isAssignableFrom(Robot.class)) {
|
||||
Robot robot = (Robot) element;
|
||||
hasRotatedTexture = TextureConverterUtil.hasRotatedTexture(robot);
|
||||
hasRotatedTexture = false;
|
||||
direction = robot.getFacingDirection();
|
||||
} else if (element.getClass().isAssignableFrom(Tile.class)) {
|
||||
Tile tile = (Tile) element;
|
||||
@ -116,7 +116,7 @@ public final class IOUtil {
|
||||
direction = tile.getDirection();
|
||||
} else if (element.getClass().isAssignableFrom(Wall.class)) {
|
||||
Wall wall = (Wall) element;
|
||||
hasRotatedTexture = TextureConverterUtil.hasRotatedTexture(wall);
|
||||
hasRotatedTexture = true;
|
||||
direction = wall.getDirection();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown element type passed to function.");
|
||||
|
@ -110,24 +110,6 @@ public final class TextureConverterUtil {
|
||||
return tileSheetTileHasRotatedTextureMappings.get(tile.getTileType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a wall has textures for different rotations
|
||||
* @param wall The wall to check
|
||||
* @return True if rotated versions of the texture exists. False otherwise
|
||||
*/
|
||||
public static boolean hasRotatedTexture(Wall wall) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a robot has textures for different rotations
|
||||
* @param robot The robot to check
|
||||
* @return True if rotated versions of the texture exists. False otherwise
|
||||
*/
|
||||
public static boolean hasRotatedTexture(Robot robot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads mappings between a tile and texture
|
||||
*
|
||||
|
Reference in New Issue
Block a user