mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-28 04:04:42 +02:00
Sletter ubrukt kode og omstruktuerer klasser
Fjerner AppTest.java Fjerner HelloWorld.java Fjerner GameBoard.java Flytter alle filer fra inf112.skeleton.app til inf112.fiasko.roborally Flytter IDrawableGame og Game til en egen pakke Flytter IDrawableObject og DrawableObject til en egen pakke Flytter GameTexture til en egen pakke
This commit is contained in:
50
src/main/java/inf112/fiasko/roborally/game/Game.java
Normal file
50
src/main/java/inf112/fiasko/roborally/game/Game.java
Normal file
@ -0,0 +1,50 @@
|
||||
package inf112.fiasko.roborally.game;
|
||||
|
||||
import inf112.fiasko.roborally.abstractions.GameTexture;
|
||||
import inf112.fiasko.roborally.objects.DrawableObject;
|
||||
import inf112.fiasko.roborally.objects.IDrawableObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
private final int TILE_NUMBER = 12;
|
||||
private final int BOARD_WIDTH = TILE_SIZE * TILE_NUMBER;
|
||||
private final int BOARD_HEIGHT = TILE_SIZE * TILE_NUMBER;
|
||||
|
||||
/**
|
||||
* Instantiates a new Game object
|
||||
*/
|
||||
public Game () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return BOARD_WIDTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return BOARD_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IDrawableObject> objectsToRender() {
|
||||
List<IDrawableObject> list = new ArrayList<>();
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int j = 0; j < 12; j++) {
|
||||
DrawableObject tileObj = new DrawableObject(i * 64, j * 64, GameTexture.TILE);
|
||||
list.add(tileObj);
|
||||
}
|
||||
}
|
||||
DrawableObject roboObj = new DrawableObject(128,128, GameTexture.ROBOT);
|
||||
list.add(roboObj);
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package inf112.fiasko.roborally.game;
|
||||
|
||||
import inf112.fiasko.roborally.objects.IDrawableObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This interface describes a game drawable using libgdx
|
||||
*/
|
||||
public interface IDrawableGame {
|
||||
|
||||
/**
|
||||
* Gets the screen width of the game
|
||||
* @return A positive integer
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* Gets the screen height of the game
|
||||
* @return A positive integer
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* Gets a list of objects which are to be rendered
|
||||
* @return A list of drawable objects in the order they are to be drawn
|
||||
*/
|
||||
List<IDrawableObject> objectsToRender();
|
||||
|
||||
}
|
Reference in New Issue
Block a user