Bytter navn fra RoboRallyLauncher til RoboRallyWrapper

This commit is contained in:
Kristian Knarvik 2020-03-02 19:09:40 +01:00
parent 52046fea40
commit e2e1fc902e
5 changed files with 29 additions and 29 deletions

View File

@ -2,7 +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.RoboRallyLauncher; import inf112.fiasko.roborally.game_wrapper.RoboRallyWrapper;
public class Main { public class Main {
@ -13,6 +13,6 @@ public class Main {
cfg.height = 900; cfg.height = 900;
cfg.samples = 3; cfg.samples = 3;
new LwjglApplication(new RoboRallyLauncher(), cfg); new LwjglApplication(new RoboRallyWrapper(), cfg);
} }
} }

View File

@ -22,7 +22,7 @@ import inf112.fiasko.roborally.utility.TextureConverterUtil;
import java.util.List; import java.util.List;
public class BoardActiveScreen implements Screen, InputProcessor { public class BoardActiveScreen implements Screen, InputProcessor {
private final RoboRallyLauncher roboRallyLauncher; private final RoboRallyWrapper roboRallyWrapper;
private final OrthographicCamera camera; private final OrthographicCamera camera;
private IDrawableGame debugGame; private IDrawableGame debugGame;
@ -35,9 +35,9 @@ public class BoardActiveScreen implements Screen, InputProcessor {
private final int viewPortHeight = 12 * tileDimensions; private final int viewPortHeight = 12 * tileDimensions;
private final Viewport viewport; private final Viewport viewport;
public BoardActiveScreen(final RoboRallyLauncher roboRallyLauncher) { public BoardActiveScreen(final RoboRallyWrapper roboRallyWrapper) {
this.roboRallyLauncher = roboRallyLauncher; this.roboRallyWrapper = roboRallyWrapper;
roboRallyLauncher.roboRallyGame = new RoboRallyGame(); roboRallyWrapper.roboRallyGame = new RoboRallyGame();
debugGame = new RoboRallyGame(true); debugGame = new RoboRallyGame(true);
camera = new OrthographicCamera(); camera = new OrthographicCamera();
@ -80,10 +80,10 @@ public class BoardActiveScreen implements Screen, InputProcessor {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT |
(Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0)); (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0));
updateCamera(); updateCamera();
roboRallyLauncher.batch.setProjectionMatrix(camera.combined); roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
roboRallyLauncher.batch.begin(); roboRallyWrapper.batch.begin();
drawBoard(roboRallyLauncher.batch); drawBoard(roboRallyWrapper.batch);
roboRallyLauncher.batch.end(); roboRallyWrapper.batch.end();
} }
@Override @Override
@ -101,8 +101,8 @@ public class BoardActiveScreen implements Screen, InputProcessor {
@Override @Override
public boolean keyUp(int keycode) { public boolean keyUp(int keycode) {
if (keycode == Input.Keys.HOME) { if (keycode == Input.Keys.HOME) {
IDrawableGame temp = roboRallyLauncher.roboRallyGame; IDrawableGame temp = roboRallyWrapper.roboRallyGame;
roboRallyLauncher.roboRallyGame = debugGame; roboRallyWrapper.roboRallyGame = debugGame;
this.debugGame = temp; this.debugGame = temp;
return true; return true;
} }
@ -175,7 +175,7 @@ public class BoardActiveScreen implements Screen, InputProcessor {
*/ */
private void drawBoard(SpriteBatch batch) { private void drawBoard(SpriteBatch batch) {
List<IDrawableObject> elementsToDraw = List<IDrawableObject> elementsToDraw =
IOUtil.getDrawableObjectsFromGame(roboRallyLauncher.roboRallyGame, tileDimensions, tileDimensions); IOUtil.getDrawableObjectsFromGame(roboRallyWrapper.roboRallyGame, tileDimensions, tileDimensions);
for (IDrawableObject object : elementsToDraw) { for (IDrawableObject object : elementsToDraw) {
TextureRegion objectTextureRegion = object.getTexture(); TextureRegion objectTextureRegion = object.getTexture();
batch.draw(objectTextureRegion.getTexture(), object.getXPosition(), object.getYPosition(), batch.draw(objectTextureRegion.getTexture(), object.getXPosition(), object.getYPosition(),

View File

@ -8,13 +8,13 @@ import com.badlogic.gdx.utils.viewport.ExtendViewport;
import com.badlogic.gdx.utils.viewport.Viewport; import com.badlogic.gdx.utils.viewport.Viewport;
public class MainMenuScreen implements Screen { public class MainMenuScreen implements Screen {
private final RoboRallyLauncher roboRallyLauncher; private final RoboRallyWrapper roboRallyWrapper;
private final OrthographicCamera camera; private final OrthographicCamera camera;
private final Viewport viewport; private final Viewport viewport;
public MainMenuScreen(final RoboRallyLauncher roboRallyLauncher) { public MainMenuScreen(final RoboRallyWrapper roboRallyWrapper) {
this.roboRallyLauncher = roboRallyLauncher; this.roboRallyWrapper = roboRallyWrapper;
camera = new OrthographicCamera(); camera = new OrthographicCamera();
camera.setToOrtho(false, 400, 400); camera.setToOrtho(false, 400, 400);
viewport = new ExtendViewport(400, 400, camera); viewport = new ExtendViewport(400, 400, camera);
@ -30,16 +30,16 @@ public class MainMenuScreen implements Screen {
Gdx.gl.glClearColor(0.2f, 1f, 0.2f, 1); Gdx.gl.glClearColor(0.2f, 1f, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update(); camera.update();
roboRallyLauncher.batch.setProjectionMatrix(camera.combined); roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
roboRallyLauncher.batch.begin(); roboRallyWrapper.batch.begin();
roboRallyLauncher.font.draw(roboRallyLauncher.batch, "Robo Rally", 0, 250, roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Robo Rally", 0, 250,
200, 0, false); 200, 0, false);
roboRallyLauncher.font.draw(roboRallyLauncher.batch, "Click anywhere to run the demo", 70, 200); roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Click anywhere to run the demo", 70, 200);
roboRallyLauncher.batch.end(); roboRallyWrapper.batch.end();
if (Gdx.input.isTouched()) { if (Gdx.input.isTouched()) {
roboRallyLauncher.setScreen(roboRallyLauncher.screenManager.getBoardActiveScreen(this.roboRallyLauncher)); roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getBoardActiveScreen(this.roboRallyWrapper));
dispose(); dispose();
} }
} }

View File

@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import inf112.fiasko.roborally.objects.IDrawableGame; import inf112.fiasko.roborally.objects.IDrawableGame;
public class RoboRallyLauncher extends Game { public class RoboRallyWrapper extends Game {
public SpriteBatch batch; public SpriteBatch batch;
public BitmapFont font; public BitmapFont font;
public ScreenManager screenManager; public ScreenManager screenManager;

View File

@ -9,24 +9,24 @@ public class ScreenManager {
/** /**
* Gets an instance of the main menu screen * Gets an instance of the main menu screen
* @param roboRallyLauncher The robo rally launcher instance to use * @param roboRallyWrapper The robo rally launcher instance to use
* @return A main menu screen instance * @return A main menu screen instance
*/ */
public synchronized MainMenuScreen getMainMenuScreen(RoboRallyLauncher roboRallyLauncher) { public synchronized MainMenuScreen getMainMenuScreen(RoboRallyWrapper roboRallyWrapper) {
if (this.mainMenuScreen == null) { if (this.mainMenuScreen == null) {
this.mainMenuScreen = new MainMenuScreen(roboRallyLauncher); this.mainMenuScreen = new MainMenuScreen(roboRallyWrapper);
} }
return mainMenuScreen; return mainMenuScreen;
} }
/** /**
* Gets an instance of the board active screen * Gets an instance of the board active screen
* @param roboRallyLauncher The robo rally launcher instance to use * @param roboRallyWrapper The robo rally launcher instance to use
* @return A board active screen instance * @return A board active screen instance
*/ */
public synchronized BoardActiveScreen getBoardActiveScreen(RoboRallyLauncher roboRallyLauncher) { public synchronized BoardActiveScreen getBoardActiveScreen(RoboRallyWrapper roboRallyWrapper) {
if (this.boardActiveScreen == null) { if (this.boardActiveScreen == null) {
this.boardActiveScreen = new BoardActiveScreen(roboRallyLauncher); this.boardActiveScreen = new BoardActiveScreen(roboRallyWrapper);
} }
return boardActiveScreen; return boardActiveScreen;
} }