mirror of
				https://github.com/inf112-v20/Fiasko.git
				synced 2025-11-04 03:33:45 +01:00 
			
		
		
		
	Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
		
							
								
								
									
										11
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								README.md
									
									
									
									
									
								
							@@ -8,6 +8,16 @@ Alle regler er hentet fra 2005 utgaven av spillguiden fra Wizards of the Coast,
 | 
				
			|||||||
## Spillstatus
 | 
					## Spillstatus
 | 
				
			||||||
Ved kjøring av .jar filen blir det kjørt en demo, uten mulighet for bruker å bevege robot.
 | 
					Ved kjøring av .jar filen blir det kjørt en demo, uten mulighet for bruker å bevege robot.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Knapper og kontrollmekanismer
 | 
				
			||||||
 | 
					### Knapper
 | 
				
			||||||
 | 
					-   Q: Tilbakestiller kamera og kamerarotasjon
 | 
				
			||||||
 | 
					-   R: Roterer kameraet
 | 
				
			||||||
 | 
					-   HOME: Bytter til en debug instans av spillet som lar en sjekke at alle teksturer vises riktig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Andre egenskaper ved brukergrensesnittet
 | 
				
			||||||
 | 
					-   Rullehjulet vil forstørre og forminske spillbrettet
 | 
				
			||||||
 | 
					-   Spillbrettet kan flyttes ved å holde inne venstre musetast og bevege musen i en retning
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Bygging og kompilering
 | 
					## Bygging og kompilering
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Forkrav for å kunne kompilere og kjøre koden
 | 
					### Forkrav for å kunne kompilere og kjøre koden
 | 
				
			||||||
@@ -22,6 +32,7 @@ cd Fiasko
 | 
				
			|||||||
mvn clean install
 | 
					mvn clean install
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
Dette vil også kjøre alle tester i koden
 | 
					Dette vil også kjøre alle tester i koden
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Kjøreprosedyre
 | 
					### Kjøreprosedyre
 | 
				
			||||||
```shell script
 | 
					```shell script
 | 
				
			||||||
cd target
 | 
					cd target
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package inf112.fiasko.roborally;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
 | 
					import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
 | 
				
			||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 | 
					import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.game_wrapper.RoboRallyWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Main {
 | 
					public class Main {
 | 
				
			||||||
@@ -10,7 +11,8 @@ public class Main {
 | 
				
			|||||||
        cfg.title = "Game Board";
 | 
					        cfg.title = "Game Board";
 | 
				
			||||||
        cfg.width = 900;
 | 
					        cfg.width = 900;
 | 
				
			||||||
        cfg.height = 900;
 | 
					        cfg.height = 900;
 | 
				
			||||||
 | 
					        cfg.samples = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        new LwjglApplication(new GameLauncher(), cfg);
 | 
					        new LwjglApplication(new RoboRallyWrapper(), cfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,35 +1,31 @@
 | 
				
			|||||||
package inf112.fiasko.roborally;
 | 
					package inf112.fiasko.roborally.game_wrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.ApplicationAdapter;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.Gdx;
 | 
					import com.badlogic.gdx.Gdx;
 | 
				
			||||||
import com.badlogic.gdx.Input;
 | 
					import com.badlogic.gdx.Input;
 | 
				
			||||||
import com.badlogic.gdx.InputProcessor;
 | 
					import com.badlogic.gdx.InputProcessor;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.Screen;
 | 
				
			||||||
import com.badlogic.gdx.graphics.GL20;
 | 
					import com.badlogic.gdx.graphics.GL20;
 | 
				
			||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
 | 
					import com.badlogic.gdx.graphics.OrthographicCamera;
 | 
				
			||||||
import com.badlogic.gdx.graphics.Texture;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 | 
					import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 | 
				
			||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
 | 
					import com.badlogic.gdx.graphics.g2d.TextureRegion;
 | 
				
			||||||
import com.badlogic.gdx.math.Vector2;
 | 
					import com.badlogic.gdx.math.Vector2;
 | 
				
			||||||
import com.badlogic.gdx.math.Vector3;
 | 
					import com.badlogic.gdx.math.Vector3;
 | 
				
			||||||
import inf112.fiasko.roborally.game.Game;
 | 
					import com.badlogic.gdx.utils.Disposable;
 | 
				
			||||||
import inf112.fiasko.roborally.game.IDrawableGame;
 | 
					import com.badlogic.gdx.utils.viewport.ExtendViewport;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.utils.viewport.Viewport;
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.objects.IDrawableGame;
 | 
				
			||||||
import inf112.fiasko.roborally.objects.IDrawableObject;
 | 
					import inf112.fiasko.roborally.objects.IDrawableObject;
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.objects.RoboRallyGame;
 | 
				
			||||||
import inf112.fiasko.roborally.utility.IOUtil;
 | 
					import inf112.fiasko.roborally.utility.IOUtil;
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.utility.TextureConverterUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					public class BoardActiveScreen implements Screen, InputProcessor {
 | 
				
			||||||
 * This class renders a game using libgdx
 | 
					    private final RoboRallyWrapper roboRallyWrapper;
 | 
				
			||||||
 */
 | 
					    private final OrthographicCamera camera;
 | 
				
			||||||
public class GameLauncher extends ApplicationAdapter implements InputProcessor {
 | 
					 | 
				
			||||||
    private OrthographicCamera camera;
 | 
					 | 
				
			||||||
    private SpriteBatch batch;
 | 
					 | 
				
			||||||
    private IDrawableGame game;
 | 
					 | 
				
			||||||
    private IDrawableGame debugGame;
 | 
					    private IDrawableGame debugGame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Texture robotTexture;
 | 
					 | 
				
			||||||
    private Texture textureSheet;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final int tileDimensions = 64;
 | 
					    private final int tileDimensions = 64;
 | 
				
			||||||
    private float cameraZoom = 1;
 | 
					    private float cameraZoom = 1;
 | 
				
			||||||
    private int cameraX = 0;
 | 
					    private int cameraX = 0;
 | 
				
			||||||
@@ -37,57 +33,64 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
 | 
				
			|||||||
    private Vector2 lastTouch;
 | 
					    private Vector2 lastTouch;
 | 
				
			||||||
    private final int viewPortWidth = 12 * tileDimensions;
 | 
					    private final int viewPortWidth = 12 * tileDimensions;
 | 
				
			||||||
    private final int viewPortHeight = 12 * tileDimensions;
 | 
					    private final int viewPortHeight = 12 * tileDimensions;
 | 
				
			||||||
 | 
					    private final Viewport viewport;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    public BoardActiveScreen(final RoboRallyWrapper roboRallyWrapper) {
 | 
				
			||||||
    public void create() {
 | 
					        this.roboRallyWrapper = roboRallyWrapper;
 | 
				
			||||||
        //Loads some textures
 | 
					        roboRallyWrapper.roboRallyGame = new RoboRallyGame();
 | 
				
			||||||
        robotTexture = new Texture(Gdx.files.internal("assets/Robot.png"));
 | 
					        debugGame = new RoboRallyGame(true);
 | 
				
			||||||
        textureSheet = new Texture(Gdx.files.internal("assets/tiles.png"));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        debugGame = new Game(true);
 | 
					 | 
				
			||||||
        game = new Game(false);
 | 
					 | 
				
			||||||
        camera = new OrthographicCamera();
 | 
					        camera = new OrthographicCamera();
 | 
				
			||||||
        camera.setToOrtho(false, viewPortWidth, viewPortHeight);
 | 
					        camera.setToOrtho(false, viewPortWidth, viewPortHeight);
 | 
				
			||||||
        camera.position.set(viewPortWidth/2f, viewPortHeight/2f, 0);
 | 
					        camera.position.set(viewPortWidth/2f, viewPortHeight/2f, 0);
 | 
				
			||||||
        batch = new SpriteBatch();
 | 
					        viewport = new ExtendViewport(viewPortWidth, viewPortHeight, camera);
 | 
				
			||||||
        /*MyTextInputListener listener = new MyTextInputListener();
 | 
					
 | 
				
			||||||
        Gdx.input.getTextInput(listener, "Input name", "", "Name");*/
 | 
					 | 
				
			||||||
        Gdx.input.setInputProcessor(this);
 | 
					        Gdx.input.setInputProcessor(this);
 | 
				
			||||||
        lastTouch = new Vector2();
 | 
					        lastTouch = new Vector2();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Renders all textures necessary to display a game
 | 
					    public void show() {
 | 
				
			||||||
     */
 | 
					        resetCamera();
 | 
				
			||||||
    public void render() {
 | 
					 | 
				
			||||||
        Gdx.gl.glClearColor(0,0,0.2f,1);
 | 
					 | 
				
			||||||
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 | 
					 | 
				
			||||||
        camera.update();
 | 
					 | 
				
			||||||
        batch.setProjectionMatrix(camera.combined);
 | 
					 | 
				
			||||||
        batch.begin();
 | 
					 | 
				
			||||||
        camera.translate(cameraX, cameraY);
 | 
					 | 
				
			||||||
        cameraX = 0;
 | 
					 | 
				
			||||||
        cameraY = 0;
 | 
					 | 
				
			||||||
        camera.zoom = cameraZoom;
 | 
					 | 
				
			||||||
        //Draws all elements the game wants to draw
 | 
					 | 
				
			||||||
        List<IDrawableObject> elementsToDraw = IOUtil.getDrawableObjectsFromGame(game, tileDimensions, tileDimensions);
 | 
					 | 
				
			||||||
        for (IDrawableObject object : elementsToDraw) {
 | 
					 | 
				
			||||||
            TextureRegion objectTextureRegion = object.getTexture();
 | 
					 | 
				
			||||||
            batch.draw(objectTextureRegion.getTexture(), object.getXPosition(), object.getYPosition(),
 | 
					 | 
				
			||||||
                    (float)object.getWidth()/2, (float)object.getHeight()/2,
 | 
					 | 
				
			||||||
                    object.getWidth(), object.getHeight(), 1, 1, object.getRotation(),
 | 
					 | 
				
			||||||
                    objectTextureRegion.getRegionX(), objectTextureRegion.getRegionY(),
 | 
					 | 
				
			||||||
                    objectTextureRegion.getRegionWidth(), objectTextureRegion.getRegionHeight(),
 | 
					 | 
				
			||||||
                    object.flipX(), object.flipY());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        batch.end();
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void resize(int width, int height) {
 | 
				
			||||||
 | 
					        viewport.update(width, height);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void pause() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void resume() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void hide() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void render(float delta) {
 | 
				
			||||||
 | 
					        Gdx.gl.glClearColor(0,0,0,1);
 | 
				
			||||||
 | 
					        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT |
 | 
				
			||||||
 | 
					                (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0));
 | 
				
			||||||
 | 
					        updateCamera();
 | 
				
			||||||
 | 
					        roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
 | 
				
			||||||
 | 
					        roboRallyWrapper.batch.begin();
 | 
				
			||||||
 | 
					        drawBoard(roboRallyWrapper.batch);
 | 
				
			||||||
 | 
					        roboRallyWrapper.batch.end();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void dispose() {
 | 
					    public void dispose() {
 | 
				
			||||||
        robotTexture.dispose();
 | 
					        for (Disposable disposable : TextureConverterUtil.getDisposableElements()) {
 | 
				
			||||||
        textureSheet.dispose();
 | 
					            disposable.dispose();
 | 
				
			||||||
        batch.dispose();
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -97,26 +100,11 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean keyUp(int keycode) {
 | 
					    public boolean keyUp(int keycode) {
 | 
				
			||||||
        switch (keycode) {
 | 
					        if (keycode == Input.Keys.HOME) {
 | 
				
			||||||
            case Input.Keys.PLUS:
 | 
					            IDrawableGame temp = roboRallyWrapper.roboRallyGame;
 | 
				
			||||||
                if (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT)) {
 | 
					            roboRallyWrapper.roboRallyGame = debugGame;
 | 
				
			||||||
                    cameraZoom -= 0.1;
 | 
					 | 
				
			||||||
                    return true;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            case Input.Keys.MINUS:
 | 
					 | 
				
			||||||
                if (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT)) {
 | 
					 | 
				
			||||||
                    cameraZoom += 0.1;
 | 
					 | 
				
			||||||
                    return true;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            case Input.Keys.HOME:
 | 
					 | 
				
			||||||
                IDrawableGame temp = game;
 | 
					 | 
				
			||||||
                this.game = debugGame;
 | 
					 | 
				
			||||||
            this.debugGame = temp;
 | 
					            this.debugGame = temp;
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
            default:
 | 
					 | 
				
			||||||
                return false;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -130,11 +118,7 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
 | 
				
			|||||||
                    new Vector3(0, 0, 1), 90);
 | 
					                    new Vector3(0, 0, 1), 90);
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        } else if (character == 'q') {
 | 
					        } else if (character == 'q') {
 | 
				
			||||||
            camera.up.x = 0;
 | 
					            resetCamera();
 | 
				
			||||||
            camera.up.y = 1;
 | 
					 | 
				
			||||||
            cameraZoom = 1;
 | 
					 | 
				
			||||||
            System.out.print((game.getHeight() * tileDimensions) - viewPortHeight/2f);
 | 
					 | 
				
			||||||
            camera.position.set(viewPortWidth/2f, viewPortHeight/2f, 0);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -157,11 +141,63 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
 | 
				
			|||||||
        Vector2 diff = newTouch.cpy().sub(lastTouch);
 | 
					        Vector2 diff = newTouch.cpy().sub(lastTouch);
 | 
				
			||||||
        lastTouch = newTouch;
 | 
					        lastTouch = newTouch;
 | 
				
			||||||
        int[] positionChange = translateCoordinateAccountingForCameraRotation(diff.x, diff.y);
 | 
					        int[] positionChange = translateCoordinateAccountingForCameraRotation(diff.x, diff.y);
 | 
				
			||||||
        cameraX = positionChange[0];
 | 
					        cameraX = (int)(positionChange[0] * cameraZoom);
 | 
				
			||||||
        cameraY = positionChange[1];
 | 
					        cameraY = (int)(positionChange[1] * cameraZoom);
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean mouseMoved(int screenX, int screenY) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean scrolled(int amount) {
 | 
				
			||||||
 | 
					        if (amount < 0 && cameraZoom > 0.3 || amount > 0 && cameraZoom < 3) {
 | 
				
			||||||
 | 
					            cameraZoom += 0.2 * amount;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Resets the camera to its initial position
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void resetCamera() {
 | 
				
			||||||
 | 
					        camera.up.x = 0;
 | 
				
			||||||
 | 
					        camera.up.y = 1;
 | 
				
			||||||
 | 
					        cameraZoom = 1;
 | 
				
			||||||
 | 
					        camera.position.set(viewPortWidth/2f, viewPortHeight/2f, 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Renders all drawable objects on the board
 | 
				
			||||||
 | 
					     * @param batch The sprite batch to use for drawing
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void drawBoard(SpriteBatch batch) {
 | 
				
			||||||
 | 
					        List<IDrawableObject> elementsToDraw =
 | 
				
			||||||
 | 
					                IOUtil.getDrawableObjectsFromGame(roboRallyWrapper.roboRallyGame, tileDimensions, tileDimensions);
 | 
				
			||||||
 | 
					        for (IDrawableObject object : elementsToDraw) {
 | 
				
			||||||
 | 
					            TextureRegion objectTextureRegion = object.getTexture();
 | 
				
			||||||
 | 
					            batch.draw(objectTextureRegion.getTexture(), object.getXPosition(), object.getYPosition(),
 | 
				
			||||||
 | 
					                    (float)object.getWidth()/2, (float)object.getHeight()/2,
 | 
				
			||||||
 | 
					                    object.getWidth(), object.getHeight(), 1, 1, object.getRotation(),
 | 
				
			||||||
 | 
					                    objectTextureRegion.getRegionX(), objectTextureRegion.getRegionY(),
 | 
				
			||||||
 | 
					                    objectTextureRegion.getRegionWidth(), objectTextureRegion.getRegionHeight(),
 | 
				
			||||||
 | 
					                    object.flipX(), object.flipY());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the camera according to any user input
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void updateCamera() {
 | 
				
			||||||
 | 
					        camera.translate(cameraX, cameraY);
 | 
				
			||||||
 | 
					        cameraX = 0;
 | 
				
			||||||
 | 
					        cameraY = 0;
 | 
				
			||||||
 | 
					        camera.zoom = cameraZoom;
 | 
				
			||||||
 | 
					        camera.update();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Translates x and y coordinates according to the camera's direction
 | 
					     * Translates x and y coordinates according to the camera's direction
 | 
				
			||||||
     * @param x The x coordinate to translate
 | 
					     * @param x The x coordinate to translate
 | 
				
			||||||
@@ -188,28 +224,4 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return new int[]{outX, outY};
 | 
					        return new int[]{outX, outY};
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public boolean mouseMoved(int screenX, int screenY) {
 | 
					 | 
				
			||||||
        return false;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public boolean scrolled(int amount) {
 | 
					 | 
				
			||||||
        if (amount < 0 && cameraZoom > 0 || amount > 0 && cameraZoom < 2) {
 | 
					 | 
				
			||||||
            cameraZoom += amount / 10.0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /*public static class MyTextInputListener implements Input.TextInputListener {
 | 
					 | 
				
			||||||
        @Override
 | 
					 | 
				
			||||||
        public void input (String text) {
 | 
					 | 
				
			||||||
            System.out.println(text);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        @Override
 | 
					 | 
				
			||||||
        public void canceled () {
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }*/
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					package inf112.fiasko.roborally.game_wrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.badlogic.gdx.Gdx;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.Screen;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.graphics.GL20;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.graphics.OrthographicCamera;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.utils.viewport.ExtendViewport;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.utils.viewport.Viewport;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MainMenuScreen implements Screen {
 | 
				
			||||||
 | 
					    private final RoboRallyWrapper roboRallyWrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final OrthographicCamera camera;
 | 
				
			||||||
 | 
					    private final Viewport viewport;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public MainMenuScreen(final RoboRallyWrapper roboRallyWrapper) {
 | 
				
			||||||
 | 
					        this.roboRallyWrapper = roboRallyWrapper;
 | 
				
			||||||
 | 
					        camera = new OrthographicCamera();
 | 
				
			||||||
 | 
					        camera.setToOrtho(false, 400, 400);
 | 
				
			||||||
 | 
					        viewport = new ExtendViewport(400, 400, camera);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void show() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void render(float delta) {
 | 
				
			||||||
 | 
					        Gdx.gl.glClearColor(0.2f, 1f, 0.2f, 1);
 | 
				
			||||||
 | 
					        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 | 
				
			||||||
 | 
					        camera.update();
 | 
				
			||||||
 | 
					        roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        roboRallyWrapper.batch.begin();
 | 
				
			||||||
 | 
					        roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Robo Rally", 0, 250,
 | 
				
			||||||
 | 
					                200, 0, false);
 | 
				
			||||||
 | 
					        roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Click anywhere to run the demo", 70, 200);
 | 
				
			||||||
 | 
					        roboRallyWrapper.batch.end();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (Gdx.input.isTouched()) {
 | 
				
			||||||
 | 
					            roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getBoardActiveScreen(this.roboRallyWrapper));
 | 
				
			||||||
 | 
					            dispose();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void resize(int width, int height) {
 | 
				
			||||||
 | 
					        viewport.update(width, height);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void pause() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void resume() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void hide() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void dispose() {
 | 
				
			||||||
 | 
					        //Nothing to do
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					package inf112.fiasko.roborally.game_wrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.badlogic.gdx.Game;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.graphics.g2d.BitmapFont;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.objects.IDrawableGame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class RoboRallyWrapper extends Game {
 | 
				
			||||||
 | 
					    public SpriteBatch batch;
 | 
				
			||||||
 | 
					    public BitmapFont font;
 | 
				
			||||||
 | 
					    public ScreenManager screenManager;
 | 
				
			||||||
 | 
					    public IDrawableGame roboRallyGame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void create() {
 | 
				
			||||||
 | 
					        batch = new SpriteBatch();
 | 
				
			||||||
 | 
					        font = new BitmapFont();
 | 
				
			||||||
 | 
					        this.screenManager = new ScreenManager();
 | 
				
			||||||
 | 
					        this.setScreen(screenManager.getMainMenuScreen(this));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void dispose() {
 | 
				
			||||||
 | 
					        batch.dispose();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					package inf112.fiasko.roborally.game_wrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Keeps track of screen instances
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class ScreenManager {
 | 
				
			||||||
 | 
					    private MainMenuScreen mainMenuScreen;
 | 
				
			||||||
 | 
					    private BoardActiveScreen boardActiveScreen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets an instance of the main menu screen
 | 
				
			||||||
 | 
					     * @param roboRallyWrapper The robo rally launcher instance to use
 | 
				
			||||||
 | 
					     * @return A main menu screen instance
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public synchronized MainMenuScreen getMainMenuScreen(RoboRallyWrapper roboRallyWrapper) {
 | 
				
			||||||
 | 
					        if (this.mainMenuScreen == null) {
 | 
				
			||||||
 | 
					            this.mainMenuScreen = new MainMenuScreen(roboRallyWrapper);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return mainMenuScreen;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets an instance of the board active screen
 | 
				
			||||||
 | 
					     * @param roboRallyWrapper The robo rally launcher instance to use
 | 
				
			||||||
 | 
					     * @return A board active screen instance
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public synchronized BoardActiveScreen getBoardActiveScreen(RoboRallyWrapper roboRallyWrapper) {
 | 
				
			||||||
 | 
					        if (this.boardActiveScreen == null) {
 | 
				
			||||||
 | 
					            this.boardActiveScreen = new BoardActiveScreen(roboRallyWrapper);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return boardActiveScreen;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,8 +1,4 @@
 | 
				
			|||||||
package inf112.fiasko.roborally.game;
 | 
					package inf112.fiasko.roborally.objects;
 | 
				
			||||||
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.objects.Robot;
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.objects.Tile;
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.objects.Wall;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,11 +1,7 @@
 | 
				
			|||||||
package inf112.fiasko.roborally.game;
 | 
					package inf112.fiasko.roborally.objects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.Position;
 | 
					import inf112.fiasko.roborally.element_properties.Position;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.RobotID;
 | 
					import inf112.fiasko.roborally.element_properties.RobotID;
 | 
				
			||||||
import inf112.fiasko.roborally.objects.Board;
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.objects.Robot;
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.objects.Tile;
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.objects.Wall;
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.utility.BoardLoaderUtil;
 | 
					import inf112.fiasko.roborally.utility.BoardLoaderUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
@@ -16,10 +12,10 @@ import java.util.concurrent.TimeUnit;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * This class represent a game which is drawable using libgdx
 | 
					 * This class represent a game which is drawable using libgdx
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Game implements IDrawableGame {
 | 
					public class RoboRallyGame implements IDrawableGame {
 | 
				
			||||||
    private Board gameBoard;
 | 
					    private Board gameBoard;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Game(boolean debug) {
 | 
					    public RoboRallyGame(boolean debug) {
 | 
				
			||||||
        if (debug) {
 | 
					        if (debug) {
 | 
				
			||||||
            initializeDebugMode();
 | 
					            initializeDebugMode();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
@@ -27,38 +23,10 @@ public class Game implements IDrawableGame {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Game() {
 | 
					    public RoboRallyGame() {
 | 
				
			||||||
        initializeGame();
 | 
					        initializeGame();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void initializeDebugMode() {
 | 
					 | 
				
			||||||
        List<Robot> robots = new ArrayList<>();
 | 
					 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            gameBoard = BoardLoaderUtil.loadBoard("boards/all_tiles_test_board.txt", robots);
 | 
					 | 
				
			||||||
        } catch (IOException e) {
 | 
					 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private void initializeGame() {
 | 
					 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            List<Robot> robots = new ArrayList<>();
 | 
					 | 
				
			||||||
            robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1)));
 | 
					 | 
				
			||||||
            robots.add(new Robot(RobotID.ROBOT_2, new Position(1, 2)));
 | 
					 | 
				
			||||||
            robots.add(new Robot(RobotID.ROBOT_3, new Position(1, 3)));
 | 
					 | 
				
			||||||
            gameBoard = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots);
 | 
					 | 
				
			||||||
            new Thread(() -> {
 | 
					 | 
				
			||||||
                try {
 | 
					 | 
				
			||||||
                    runGameLoop();
 | 
					 | 
				
			||||||
                } catch (InterruptedException e) {
 | 
					 | 
				
			||||||
                    Thread.currentThread().interrupt();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }).start();
 | 
					 | 
				
			||||||
        } catch (IOException e) {
 | 
					 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getWidth() {
 | 
					    public int getWidth() {
 | 
				
			||||||
        return gameBoard.getBoardWidth();
 | 
					        return gameBoard.getBoardWidth();
 | 
				
			||||||
@@ -84,6 +52,43 @@ public class Game implements IDrawableGame {
 | 
				
			|||||||
        return gameBoard.getAliveRobots();
 | 
					        return gameBoard.getAliveRobots();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Initializes the game with a debugging board
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void initializeDebugMode() {
 | 
				
			||||||
 | 
					        List<Robot> robots = new ArrayList<>();
 | 
				
			||||||
 | 
					        robots.add(new Robot(RobotID.ROBOT_1, new Position(0, 16)));
 | 
				
			||||||
 | 
					        robots.add(new Robot(RobotID.ROBOT_2, new Position(1, 16)));
 | 
				
			||||||
 | 
					        robots.add(new Robot(RobotID.ROBOT_3, new Position(2, 16)));
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            gameBoard = BoardLoaderUtil.loadBoard("boards/all_tiles_test_board.txt", robots);
 | 
				
			||||||
 | 
					        } catch (IOException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Initializes the game with a playable board
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void initializeGame() {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            List<Robot> robots = new ArrayList<>();
 | 
				
			||||||
 | 
					            robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1)));
 | 
				
			||||||
 | 
					            robots.add(new Robot(RobotID.ROBOT_2, new Position(1, 2)));
 | 
				
			||||||
 | 
					            robots.add(new Robot(RobotID.ROBOT_3, new Position(1, 3)));
 | 
				
			||||||
 | 
					            gameBoard = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots);
 | 
				
			||||||
 | 
					            new Thread(() -> {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    runGameLoop();
 | 
				
			||||||
 | 
					                } catch (InterruptedException e) {
 | 
				
			||||||
 | 
					                    Thread.currentThread().interrupt();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }).start();
 | 
				
			||||||
 | 
					        } catch (IOException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Does whatever the game wants to do
 | 
					     * Does whatever the game wants to do
 | 
				
			||||||
     * @throws InterruptedException If interrupted while trying to sleep
 | 
					     * @throws InterruptedException If interrupted while trying to sleep
 | 
				
			||||||
@@ -17,6 +17,9 @@ public class Wall {
 | 
				
			|||||||
     * @param direction The direction of the wall
 | 
					     * @param direction The direction of the wall
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Wall (WallType wallType, Direction direction) {
 | 
					    public Wall (WallType wallType, Direction direction) {
 | 
				
			||||||
 | 
					        if (direction.getDirectionID() % 2 == 0 && wallType != WallType.WALL_CORNER) {
 | 
				
			||||||
 | 
					            throw new IllegalArgumentException("Invalid direction for wall type submitted");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        this.wallType = wallType;
 | 
					        this.wallType = wallType;
 | 
				
			||||||
        this.direction = direction;
 | 
					        this.direction = direction;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,7 +86,7 @@ public final class BoardLoaderUtil {
 | 
				
			|||||||
                WallType wallType = WallType.getWallTypeFromID(Integer.parseInt(wallData[0]));
 | 
					                WallType wallType = WallType.getWallTypeFromID(Integer.parseInt(wallData[0]));
 | 
				
			||||||
                Direction direction = Direction.getDirectionFromID(Integer.parseInt(wallData[1]));
 | 
					                Direction direction = Direction.getDirectionFromID(Integer.parseInt(wallData[1]));
 | 
				
			||||||
                if (direction == null) {
 | 
					                if (direction == null) {
 | 
				
			||||||
                    throw new IllegalArgumentException("Invalid direction for tile encountered when loading board file.");
 | 
					                    throw new IllegalArgumentException("Invalid direction for wall encountered when loading board file.");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                wallGrid.setElement(x, y, new Wall(wallType, direction));
 | 
					                wallGrid.setElement(x, y, new Wall(wallType, direction));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ package inf112.fiasko.roborally.utility;
 | 
				
			|||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
 | 
					import com.badlogic.gdx.graphics.g2d.TextureRegion;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.Direction;
 | 
					import inf112.fiasko.roborally.element_properties.Direction;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.Position;
 | 
					import inf112.fiasko.roborally.element_properties.Position;
 | 
				
			||||||
import inf112.fiasko.roborally.game.IDrawableGame;
 | 
					import inf112.fiasko.roborally.objects.IDrawableGame;
 | 
				
			||||||
import inf112.fiasko.roborally.objects.DrawableObject;
 | 
					import inf112.fiasko.roborally.objects.DrawableObject;
 | 
				
			||||||
import inf112.fiasko.roborally.objects.IDrawableObject;
 | 
					import inf112.fiasko.roborally.objects.IDrawableObject;
 | 
				
			||||||
import inf112.fiasko.roborally.objects.Robot;
 | 
					import inf112.fiasko.roborally.objects.Robot;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ package inf112.fiasko.roborally.utility;
 | 
				
			|||||||
import com.badlogic.gdx.Gdx;
 | 
					import com.badlogic.gdx.Gdx;
 | 
				
			||||||
import com.badlogic.gdx.graphics.Texture;
 | 
					import com.badlogic.gdx.graphics.Texture;
 | 
				
			||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
 | 
					import com.badlogic.gdx.graphics.g2d.TextureRegion;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.utils.Disposable;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.Direction;
 | 
					import inf112.fiasko.roborally.element_properties.Direction;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.RobotID;
 | 
					import inf112.fiasko.roborally.element_properties.RobotID;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.TileType;
 | 
					import inf112.fiasko.roborally.element_properties.TileType;
 | 
				
			||||||
@@ -15,7 +16,9 @@ import java.io.BufferedReader;
 | 
				
			|||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.io.InputStream;
 | 
					import java.io.InputStream;
 | 
				
			||||||
import java.io.InputStreamReader;
 | 
					import java.io.InputStreamReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -32,6 +35,19 @@ public final class TextureConverterUtil {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private TextureConverterUtil() {}
 | 
					    private TextureConverterUtil() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets a list of all disposable elements which should be disposed when the software closes
 | 
				
			||||||
 | 
					     * @return A list of disposable elements
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static List<Disposable> getDisposableElements() {
 | 
				
			||||||
 | 
					        List<Disposable> disposables = new ArrayList<>();
 | 
				
			||||||
 | 
					        disposables.add(textureSheet);
 | 
				
			||||||
 | 
					        disposables.add(robot1Texture);
 | 
				
			||||||
 | 
					        disposables.add(robot2Texture);
 | 
				
			||||||
 | 
					        disposables.add(robot3Texture);
 | 
				
			||||||
 | 
					        return disposables;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets the texture representing the tile
 | 
					     * Gets the texture representing the tile
 | 
				
			||||||
     * @param tile The tile to draw
 | 
					     * @param tile The tile to draw
 | 
				
			||||||
 
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 18 MiB After Width: | Height: | Size: 17 MiB  | 
@@ -1,4 +1,4 @@
 | 
				
			|||||||
8 16
 | 
					8 19
 | 
				
			||||||
01;1 01;3 01;5 01;7 02;1 02;3 02;5 02;7
 | 
					01;1 01;3 01;5 01;7 02;1 02;3 02;5 02;7
 | 
				
			||||||
03;1 03;3 03;5 03;7 04;1 04;3 04;5 04;7
 | 
					03;1 03;3 03;5 03;7 04;1 04;3 04;5 04;7
 | 
				
			||||||
05;1 05;3 05;5 05;7 06;1 06;3 06;5 06;7
 | 
					05;1 05;3 05;5 05;7 06;1 06;3 06;5 06;7
 | 
				
			||||||
@@ -15,6 +15,9 @@
 | 
				
			|||||||
27;1 27;3 27;5 27;7 28;1 28;3 28;5 28;7
 | 
					27;1 27;3 27;5 27;7 28;1 28;3 28;5 28;7
 | 
				
			||||||
29;1 29;3 29;5 29;7 30;1 30;3 30;5 30;7
 | 
					29;1 29;3 29;5 29;7 30;1 30;3 30;5 30;7
 | 
				
			||||||
31;1 31;3 31;5 31;7 01;1 01;1 01;1 01;1
 | 
					31;1 31;3 31;5 31;7 01;1 01;1 01;1 01;1
 | 
				
			||||||
 | 
					01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
 | 
				
			||||||
 | 
					01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
 | 
				
			||||||
 | 
					01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
 | 
				
			||||||
0 0 0 0 0 0 0 0
 | 
					0 0 0 0 0 0 0 0
 | 
				
			||||||
0 0 0 0 0 0 0 0
 | 
					0 0 0 0 0 0 0 0
 | 
				
			||||||
0 0 0 0 0 0 0 0
 | 
					0 0 0 0 0 0 0 0
 | 
				
			||||||
@@ -31,3 +34,6 @@
 | 
				
			|||||||
0 0 0 0 0 0 0 0
 | 
					0 0 0 0 0 0 0 0
 | 
				
			||||||
0 0 0 0 0 0 0 0
 | 
					0 0 0 0 0 0 0 0
 | 
				
			||||||
0 0 0 0 0 0 0 0
 | 
					0 0 0 0 0 0 0 0
 | 
				
			||||||
 | 
					0 0 0 0 0 0 0 0
 | 
				
			||||||
 | 
					1;1 1;3 1;5 1;7 2;2 2;4 2;6 2;8
 | 
				
			||||||
 | 
					3;1 3;3 3;5 3;7 4;1 4;3 4;5 4;7
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
WALL_NORMAL 6 3 6 2 4 3 5 3
 | 
					WALL_NORMAL 6 3 6 2 4 3 5 3
 | 
				
			||||||
WALL_CORNER 7 0 7 1 7 3 7 2
 | 
					WALL_CORNER 7 1 7 0 7 3 7 2
 | 
				
			||||||
WALL_LASER_SINGLE 4 5 5 5 4 4 5 4
 | 
					WALL_LASER_SINGLE 4 5 5 5 4 4 5 4
 | 
				
			||||||
WALL_LASER_DOUBLE 5 11 6 11 6 10 5 11
 | 
					WALL_LASER_DOUBLE 5 11 6 11 6 10 4 11
 | 
				
			||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package inf112.fiasko.roborally.element_properties;
 | 
					package inf112.fiasko.roborally.element_properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.objects.Tile;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
@@ -44,6 +45,11 @@ public class TileTypeTest {
 | 
				
			|||||||
        assertNull(TileType.getTileTypeFromID(-1));
 | 
					        assertNull(TileType.getTileTypeFromID(-1));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test (expected = IllegalArgumentException.class)
 | 
				
			||||||
 | 
					    public void invalidTileDirectionThrowsError() {
 | 
				
			||||||
 | 
					        new Tile(TileType.TILE, Direction.NORTH_EAST);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void allTilesHaveUniqueId() {
 | 
					    public void allTilesHaveUniqueId() {
 | 
				
			||||||
        /* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
 | 
					        /* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package inf112.fiasko.roborally.element_properties;
 | 
					package inf112.fiasko.roborally.element_properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.objects.Wall;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
@@ -44,6 +45,11 @@ public class WallTypeTest {
 | 
				
			|||||||
        assertNull(TileType.getTileTypeFromID(-1));
 | 
					        assertNull(TileType.getTileTypeFromID(-1));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test (expected = IllegalArgumentException.class)
 | 
				
			||||||
 | 
					    public void invalidWallDirectionThrowsError() {
 | 
				
			||||||
 | 
					        new Wall(WallType.WALL_NORMAL, Direction.NORTH_EAST);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void allWallsHaveUniqueId() {
 | 
					    public void allWallsHaveUniqueId() {
 | 
				
			||||||
        /* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
 | 
					        /* This test is also done implicitly by the allTileTypesIDConversionToIDAndBack test, but that test may fail
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,16 @@
 | 
				
			|||||||
package inf112.fiasko.roborally.game;
 | 
					package inf112.fiasko.roborally.objects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.junit.Assert.assertTrue;
 | 
					import static org.junit.Assert.assertTrue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.junit.Before;
 | 
					import org.junit.Before;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GameTest {
 | 
					public class RoboRallyGameTest {
 | 
				
			||||||
    private IDrawableGame game;
 | 
					    private IDrawableGame game;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Before
 | 
					    @Before
 | 
				
			||||||
    public void setUp() {
 | 
					    public void setUp() {
 | 
				
			||||||
        game = new Game();
 | 
					        game = new RoboRallyGame();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
		Reference in New Issue
	
	Block a user