mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-04-21 11:06:24 +02:00
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
72 lines
2.5 KiB
Java
72 lines
2.5 KiB
Java
package inf112.fiasko.roborally;
|
|
|
|
import com.badlogic.gdx.ApplicationAdapter;
|
|
import com.badlogic.gdx.Gdx;
|
|
import com.badlogic.gdx.graphics.GL20;
|
|
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.TextureRegion;
|
|
import inf112.fiasko.roborally.game.Game;
|
|
import inf112.fiasko.roborally.game.IDrawableGame;
|
|
import inf112.fiasko.roborally.objects.IDrawableObject;
|
|
import inf112.fiasko.roborally.utility.IOUtil;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* This class renders a game using libgdx
|
|
*/
|
|
public class GameLauncher extends ApplicationAdapter {
|
|
private OrthographicCamera camera;
|
|
private SpriteBatch batch;
|
|
private IDrawableGame game;
|
|
|
|
private Texture robotTexture;
|
|
private Texture textureSheet;
|
|
|
|
private final int tileDimensions = 64;
|
|
|
|
@Override
|
|
public void create() {
|
|
//Loads some textures
|
|
robotTexture = new Texture(Gdx.files.internal("assets/Robot.png"));
|
|
textureSheet = new Texture(Gdx.files.internal("assets/tiles.png"));
|
|
|
|
game = new Game();
|
|
camera = new OrthographicCamera();
|
|
camera.setToOrtho(false, game.getWidth() * tileDimensions,
|
|
game.getHeight() * tileDimensions);
|
|
batch = new SpriteBatch();
|
|
}
|
|
|
|
/**
|
|
* Renders all textures necessary to display a game
|
|
*/
|
|
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();
|
|
//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 dispose() {
|
|
robotTexture.dispose();
|
|
textureSheet.dispose();
|
|
batch.dispose();
|
|
}
|
|
} |