mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
commit
11139cb5f8
@ -0,0 +1,30 @@
|
|||||||
|
package inf112.fiasko.roborally.game_wrapper;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Screen;
|
||||||
|
|
||||||
|
public abstract class AbstractScreen implements Screen {
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,7 @@ import inf112.fiasko.roborally.utility.TextureConverterUtil;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BoardActiveScreen implements Screen, InputProcessor {
|
public class BoardActiveScreen extends AbstractScreen implements InputProcessor {
|
||||||
private final RoboRallyWrapper roboRallyWrapper;
|
private final RoboRallyWrapper roboRallyWrapper;
|
||||||
private final OrthographicCamera camera;
|
private final OrthographicCamera camera;
|
||||||
private IDrawableGame debugGame;
|
private IDrawableGame debugGame;
|
||||||
@ -59,20 +59,6 @@ public class BoardActiveScreen implements Screen, InputProcessor {
|
|||||||
viewport.update(width, 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
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
|
@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
|
|||||||
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
|
|
||||||
public class LoadingScreen implements Screen {
|
public class LoadingScreen extends AbstractScreen {
|
||||||
private final RoboRallyWrapper roboRallyWrapper;
|
private final RoboRallyWrapper roboRallyWrapper;
|
||||||
|
|
||||||
private final OrthographicCamera camera;
|
private final OrthographicCamera camera;
|
||||||
@ -25,10 +25,6 @@ public class LoadingScreen implements Screen {
|
|||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
@ -53,23 +49,4 @@ public class LoadingScreen implements Screen {
|
|||||||
viewport.update(width, 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
|
|||||||
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
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 extends AbstractScreen {
|
||||||
private final RoboRallyWrapper roboRallyWrapper;
|
private final RoboRallyWrapper roboRallyWrapper;
|
||||||
|
|
||||||
private final OrthographicCamera camera;
|
private final OrthographicCamera camera;
|
||||||
@ -20,11 +20,6 @@ public class MainMenuScreen implements Screen {
|
|||||||
viewport = new ExtendViewport(400, 400, camera);
|
viewport = new ExtendViewport(400, 400, camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(0.2f, 1f, 0.2f, 1);
|
Gdx.gl.glClearColor(0.2f, 1f, 0.2f, 1);
|
||||||
@ -50,23 +45,4 @@ public class MainMenuScreen implements Screen {
|
|||||||
viewport.update(width, 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package inf112.fiasko.roborally.game_wrapper;
|
package inf112.fiasko.roborally.game_wrapper;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
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.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
@ -11,7 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
|||||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
|
|
||||||
public class PowerDownScreen implements Screen {
|
public class PowerDownScreen extends AbstractScreen {
|
||||||
private final RoboRallyWrapper roboRallyWrapper;
|
private final RoboRallyWrapper roboRallyWrapper;
|
||||||
|
|
||||||
private final OrthographicCamera camera;
|
private final OrthographicCamera camera;
|
||||||
@ -20,15 +19,15 @@ public class PowerDownScreen implements Screen {
|
|||||||
private long startTime;
|
private long startTime;
|
||||||
private final int applicationWidth = 600;
|
private final int applicationWidth = 600;
|
||||||
private final int applicationHeight = 800;
|
private final int applicationHeight = 800;
|
||||||
private Boolean press = false;
|
private Boolean buttonPressed = false;
|
||||||
public PowerDownScreen(final RoboRallyWrapper roboRallyWrapper) {
|
public PowerDownScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||||
camera = new OrthographicCamera();
|
camera = new OrthographicCamera();
|
||||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
stage = new Stage();
|
stage = new Stage();
|
||||||
TextButton powerDownButton = new SimpleButton("PowerDown", roboRallyWrapper.font).getButton();
|
TextButton powerDownButton = new SimpleButton("PowerDown", roboRallyWrapper.font).getButton();
|
||||||
stage.addActor(powerDownButton);
|
stage.addActor(powerDownButton);
|
||||||
powerDownButton.setY(applicationHeight/2f);
|
powerDownButton.setY(applicationHeight / 2f);
|
||||||
powerDownButton.setX(applicationWidth/2f+powerDownButton.getWidth()/4f);
|
powerDownButton.setX(applicationWidth / 2f + powerDownButton.getWidth() / 4f);
|
||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
Gdx.input.setInputProcessor(stage);
|
||||||
@ -36,16 +35,12 @@ public class PowerDownScreen implements Screen {
|
|||||||
powerDownButton.addListener(new InputListener() {
|
powerDownButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
press = true;
|
buttonPressed = true;
|
||||||
return true;//her we do stuff
|
return true;//her we do stuff
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
@ -54,18 +49,20 @@ public class PowerDownScreen implements Screen {
|
|||||||
camera.update();
|
camera.update();
|
||||||
roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
|
roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
|
||||||
|
|
||||||
|
int elapsedTime = (int)Math.floor((System.currentTimeMillis() - startTime) / 1000f);
|
||||||
|
|
||||||
roboRallyWrapper.batch.begin();
|
roboRallyWrapper.batch.begin();
|
||||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, "click to go in PowerDown you have 10 seconds",
|
roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Click the button to enter Power Down next round",
|
||||||
applicationWidth/2f-380/2f,applicationHeight/2f +100,380, 1, true);
|
applicationWidth/2f-380/2f,applicationHeight/2f + 100,380, 1, true);
|
||||||
|
roboRallyWrapper.font.draw(roboRallyWrapper.batch, String.valueOf(10 - elapsedTime),
|
||||||
|
applicationWidth / 2f - 40 / 2f,applicationHeight/2f - 100,40, 1, true);
|
||||||
roboRallyWrapper.batch.end();
|
roboRallyWrapper.batch.end();
|
||||||
stage.draw();
|
stage.draw();
|
||||||
|
|
||||||
long time = System.currentTimeMillis();
|
if (elapsedTime > 10) {
|
||||||
if (time-startTime>10000){
|
|
||||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getMainMenuScreen(this.roboRallyWrapper));
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getMainMenuScreen(this.roboRallyWrapper));
|
||||||
dispose();
|
dispose();
|
||||||
}
|
} else if (buttonPressed) {
|
||||||
else if (press){
|
|
||||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
@ -76,24 +73,4 @@ public class PowerDownScreen implements Screen {
|
|||||||
viewport.update(width, 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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
|||||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
|
|
||||||
public class StartMenuScreen implements Screen {
|
public class StartMenuScreen extends AbstractScreen {
|
||||||
private final RoboRallyWrapper roboRallyWrapper;
|
private final RoboRallyWrapper roboRallyWrapper;
|
||||||
|
|
||||||
private final OrthographicCamera camera;
|
private final OrthographicCamera camera;
|
||||||
@ -20,7 +20,6 @@ public class StartMenuScreen implements Screen {
|
|||||||
private final Stage stage;
|
private final Stage stage;
|
||||||
private final int applicationWidth = 600;
|
private final int applicationWidth = 600;
|
||||||
private final int applicationHeight = 800;
|
private final int applicationHeight = 800;
|
||||||
private Boolean press = false;
|
|
||||||
public StartMenuScreen(final RoboRallyWrapper roboRallyWrapper) {
|
public StartMenuScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||||
camera = new OrthographicCamera();
|
camera = new OrthographicCamera();
|
||||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
@ -33,13 +32,38 @@ public class StartMenuScreen implements Screen {
|
|||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
Gdx.input.setInputProcessor(stage);
|
||||||
|
Input.TextInputListener nameInputClient = new Input.TextInputListener() {
|
||||||
|
@Override
|
||||||
|
public void input(String name) {
|
||||||
|
//TODO: do something with the name
|
||||||
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getMainMenuScreen(roboRallyWrapper));
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void canceled() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Input.TextInputListener nameInputServer = new Input.TextInputListener() {
|
||||||
|
@Override
|
||||||
|
public void input(String name) {
|
||||||
|
//TODO: do something with the name
|
||||||
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(roboRallyWrapper));
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void canceled() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
serverButton.addListener(new InputListener() {
|
serverButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
MyTextInputListener nameinput = new MyTextInputListener();
|
Gdx.input.getTextInput(nameInputServer, "Name input", "input name her", "");
|
||||||
Gdx.input.getTextInput(nameinput, "Name input", "input name her", "");
|
return true; // Here do stuff
|
||||||
press = true;
|
|
||||||
return true;//her we do stuff
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,11 +76,8 @@ public class StartMenuScreen implements Screen {
|
|||||||
clientButton.addListener(new InputListener() {
|
clientButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
press = true;
|
Gdx.input.getTextInput(nameInputClient, "Name input", "input name her", "");
|
||||||
MyTextInputListener nameinput = new MyTextInputListener();
|
return true;// Here we do stuff
|
||||||
Gdx.input.getTextInput(nameinput, "Name input", "input name her", "");
|
|
||||||
|
|
||||||
return true;//her we do stuff
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -76,11 +97,6 @@ public class StartMenuScreen implements Screen {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
@ -93,11 +109,6 @@ public class StartMenuScreen implements Screen {
|
|||||||
applicationWidth/2f-380/2f,applicationHeight/2f +100,380, 1, true);
|
applicationWidth/2f-380/2f,applicationHeight/2f +100,380, 1, true);
|
||||||
roboRallyWrapper.batch.end();
|
roboRallyWrapper.batch.end();
|
||||||
stage.draw();
|
stage.draw();
|
||||||
|
|
||||||
if (press){
|
|
||||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,24 +116,4 @@ public class StartMenuScreen implements Screen {
|
|||||||
viewport.update(width, 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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user