2020-02-04 17:52:17 +01:00
|
|
|
package inf112.fiasko.roborally.game;
|
|
|
|
|
2020-02-19 11:20:06 +01:00
|
|
|
import inf112.fiasko.roborally.element_properties.GameTexture;
|
2020-02-22 23:36:01 +01:00
|
|
|
import inf112.fiasko.roborally.objects.Board;
|
2020-02-04 17:52:17 +01:00
|
|
|
import inf112.fiasko.roborally.objects.DrawableObject;
|
|
|
|
import inf112.fiasko.roborally.objects.IDrawableObject;
|
2020-02-22 23:36:01 +01:00
|
|
|
import inf112.fiasko.roborally.objects.Robot;
|
|
|
|
import inf112.fiasko.roborally.utility.BoardLoaderUtil;
|
2020-01-31 13:53:08 +01:00
|
|
|
|
2020-02-22 23:36:01 +01:00
|
|
|
import java.io.IOException;
|
2020-02-03 14:10:52 +01:00
|
|
|
import java.util.ArrayList;
|
2020-01-31 13:53:08 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class represent a game which is drawable using libgdx
|
|
|
|
*/
|
|
|
|
public class Game implements IDrawableGame {
|
|
|
|
private final int TILE_SIZE = 64;
|
2020-02-22 23:36:01 +01:00
|
|
|
private Board gameBoard;
|
|
|
|
|
|
|
|
public Game() {
|
|
|
|
try {
|
|
|
|
List<Robot> robots = new ArrayList<>();
|
|
|
|
gameBoard = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots);
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2020-01-31 13:53:08 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getWidth() {
|
2020-02-22 23:36:01 +01:00
|
|
|
return gameBoard.getBoardWidth() * TILE_SIZE;
|
2020-01-31 13:53:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getHeight() {
|
2020-02-22 23:36:01 +01:00
|
|
|
return gameBoard.getBoardHeight() * TILE_SIZE;
|
2020-01-31 13:53:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-02-05 05:14:35 +01:00
|
|
|
public List<IDrawableObject> getObjectsToDraw() {
|
2020-02-03 14:10:52 +01:00
|
|
|
List<IDrawableObject> list = new ArrayList<>();
|
2020-02-22 23:36:01 +01:00
|
|
|
for (int i = 0; i < gameBoard.getBoardWidth(); i++) {
|
|
|
|
for (int j = 0; j < gameBoard.getBoardHeight(); j++) {
|
2020-02-05 05:14:35 +01:00
|
|
|
DrawableObject tile = new DrawableObject(GameTexture.TILE, i * TILE_SIZE, j * TILE_SIZE);
|
|
|
|
list.add(tile);
|
2020-02-03 14:10:52 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-05 05:14:35 +01:00
|
|
|
DrawableObject robot = new DrawableObject(GameTexture.ROBOT, TILE_SIZE, TILE_SIZE);
|
|
|
|
list.add(robot);
|
2020-02-03 14:10:52 +01:00
|
|
|
return list;
|
2020-01-31 13:53:08 +01:00
|
|
|
}
|
|
|
|
}
|