Jan Ehehalt 6 years ago
parent 1393b053f8
commit 2124035fa2

@ -54,7 +54,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
@Override @Override
public void create(){ public void create(){
ts = new Titlescreen(); ts = new Titlescreen(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
ls = null; ls = null;
gs = null; gs = null;
ws = null; ws = null;
@ -81,7 +81,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
level.reset(); level.reset();
gs.dispose(); gs.dispose();
gs = null; gs = null;
ws = new Winscreen(); ws = new Winscreen(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
} }
else{ else{
level.step(); level.step();
@ -139,7 +139,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(ts != null){ if(ts != null){
ts.dispose(); ts.dispose();
ts = null; ts = null;
ls = new Levelscreen(levelAmount); ls = new Levelscreen(levelAmount, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
} }
else if(ls != null){ else if(ls != null){
if(x < Gdx.graphics.getWidth() * 0.15){ if(x < Gdx.graphics.getWidth() * 0.15){
@ -152,7 +152,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
else{ else{
ls.dispose(); ls.dispose();
ls = null; ls = null;
gs = new Gamescreen(level); gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
stepTimer.start(); stepTimer.start();
} }
} }
@ -163,13 +163,13 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
} }
else if(ws != null){ else if(ws != null){
if(x < Gdx.graphics.getWidth() * 0.33){ if(x < Gdx.graphics.getWidth() * 0.33){
ls = new Levelscreen(levelAmount); ls = new Levelscreen(levelAmount, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
} }
else if(x < Gdx.graphics.getWidth() * 0.66){ else if(x < Gdx.graphics.getWidth() * 0.66){
gs = new Gamescreen(level); gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
} }
else{ else{
gs = new Gamescreen(level); gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
} }
ws = null; ws = null;
} }

@ -32,9 +32,12 @@ public class Gamescreen{
int pivotX; int pivotX;
int pivotY; int pivotY;
float GAME_WORLD_WIDTH;
float GAME_WORLD_HEIGHT;
public Gamescreen(Level level, float width, float height){
public Gamescreen(Level level){ GAME_WORLD_WIDTH = width;
GAME_WORLD_HEIGHT = height;
pivotX = level.getPivotX(); pivotX = level.getPivotX();
pivotY = level.getPivotY(); pivotY = level.getPivotY();
g = level.getGoal(); g = level.getGoal();
@ -77,6 +80,7 @@ public class Gamescreen{
shapeRenderer.circle((float) p.getxPos(), (float) p.getyPos(), p.getRadius()); shapeRenderer.circle((float) p.getxPos(), (float) p.getyPos(), p.getRadius());
shapeRenderer.setColor(Color.GRAY); shapeRenderer.setColor(Color.GRAY);
shapeRenderer.circle(pivotX, pivotY, 5); shapeRenderer.circle(pivotX, pivotY, 5);
shapeRenderer.circle(0,0,5);
shapeRenderer.end(); shapeRenderer.end();

@ -33,14 +33,18 @@ public class Levelscreen{
Timer t; Timer t;
boolean movement; boolean movement;
int levelAmount; int levelAmount;
float GAME_WORLD_WIDTH;
float GAME_WORLD_HEIGHT;
public Levelscreen(int levelAmount){ public Levelscreen(int levelAmount, float width, float height){
GAME_WORLD_WIDTH = width;
GAME_WORLD_HEIGHT = height;
levelPreview = new Sprite[levelAmount]; levelPreview = new Sprite[levelAmount];
buttonRight = new Sprite(new Texture("buttonRight.png")); buttonRight = new Sprite(new Texture("buttonRight.png"));
buttonRight.setY(Gdx.graphics.getHeight() / 2 - buttonRight.getHeight() / 2); buttonRight.setY(GAME_WORLD_HEIGHT/ 2 - buttonRight.getHeight() / 2);
buttonRight.setX(Gdx.graphics.getWidth() - 10 - buttonRight.getWidth()); buttonRight.setX(GAME_WORLD_WIDTH - 10 - buttonRight.getWidth());
buttonLeft = new Sprite(new Texture("buttonLeft.png")); buttonLeft = new Sprite(new Texture("buttonLeft.png"));
buttonLeft.setY(Gdx.graphics.getHeight() / 2 - buttonLeft.getHeight() / 2); buttonLeft.setY(GAME_WORLD_HEIGHT / 2 - buttonLeft.getHeight() / 2);
buttonLeft.setX(10); buttonLeft.setX(10);
selectedLevel = 0; selectedLevel = 0;
this.levelAmount = levelAmount; this.levelAmount = levelAmount;
@ -56,7 +60,7 @@ public class Levelscreen{
if(buttonLeft.getX() <= 0){ if(buttonLeft.getX() <= 0){
movement = true; movement = true;
} }
if(buttonLeft.getX() + buttonLeft.getWidth() > Gdx.graphics.getWidth() * 0.12){ if(buttonLeft.getX() + buttonLeft.getWidth() > GAME_WORLD_WIDTH * 0.12){
movement = false; movement = false;
} }
if(movement){ if(movement){
@ -79,7 +83,7 @@ public class Levelscreen{
if(selectedLevel < levelAmount){ if(selectedLevel < levelAmount){
buttonRight.draw(batch); buttonRight.draw(batch);
} }
font.draw(batch, "" + selectedLevel, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2); font.draw(batch, "" + selectedLevel, GAME_WORLD_WIDTH / 2, GAME_WORLD_HEIGHT / 2);
} }

@ -26,20 +26,24 @@ public class Titlescreen{
Timer t; Timer t;
Sprite clicktostart; Sprite clicktostart;
boolean movement; boolean movement;
float GAME_WORLD_WIDTH;
float GAME_WORLD_HEIGHT;
public Titlescreen(){ public Titlescreen(float width, float height){
this.GAME_WORLD_WIDTH = width;
this.GAME_WORLD_HEIGHT = height;
movement = true; movement = true;
clicktostart = new Sprite(new Texture(Gdx.files.internal("clicktostart.png"))); clicktostart = new Sprite(new Texture(Gdx.files.internal("clicktostart.png")));
clicktostart.setX(Gdx.graphics.getWidth() / 2 - clicktostart.getWidth() / 2); clicktostart.setX(GAME_WORLD_WIDTH / 2 - clicktostart.getWidth() / 2);
clicktostart.setY(Gdx.graphics.getHeight() / 2 - clicktostart.getHeight() / 2); clicktostart.setY(GAME_WORLD_HEIGHT / 2 - clicktostart.getHeight() / 2);
t = new Timer(); t = new Timer();
t.scheduleTask(new Timer.Task() { t.scheduleTask(new Timer.Task() {
@Override @Override
public void run() { public void run() {
if(clicktostart.getY() < Gdx.graphics.getHeight() * 0.4) if(clicktostart.getY() < GAME_WORLD_HEIGHT * 0.4)
movement = true; movement = true;
else if(clicktostart.getY() > Gdx.graphics.getHeight() * 0.5) else if(clicktostart.getY() > GAME_WORLD_HEIGHT * 0.5)
movement = false; movement = false;
if(movement) if(movement)
clicktostart.setY(clicktostart.getY() + 3); clicktostart.setY(clicktostart.getY() + 3);

@ -27,17 +27,22 @@ public class Winscreen{
Sprite win; Sprite win;
boolean movement; boolean movement;
float GAME_WORLD_WIDTH;
float GAME_WORLD_HEIGHT;
public Winscreen(){ public Winscreen(float width, float height){
t = new Timer(); t = new Timer();
GAME_WORLD_WIDTH = width;
GAME_WORLD_HEIGHT = height;
/* /*
movement = true; movement = true;
win = new Sprite(new Texture(Gdx.files.internal("win.png"))); win = new Sprite(new Texture(Gdx.files.internal("win.png")));
win.setX(Gdx.graphics.getWidth() / 2 - win.getWidth() / 2); win.setX(GAME_WORLD_WIDTH / 2 - win.getWidth() / 2);
win.setY(Gdx.graphics.getHeight() * 0.7f - win.getHeight() / 2); win.setY(GAME_WORLD_HEIGHT * 0.7f - win.getHeight() / 2);
*/ */
int w = Gdx.graphics.getWidth(); float w = GAME_WORLD_WIDTH;
int h = Gdx.graphics.getHeight(); float h = GAME_WORLD_HEIGHT;
next = new Sprite(new Texture("skipicon.png")); next = new Sprite(new Texture("skipicon.png"));
next.setPosition(w * 0.75f - next.getWidth()/2, h*0.35f - next.getHeight()/2); next.setPosition(w * 0.75f - next.getWidth()/2, h*0.35f - next.getHeight()/2);
@ -51,9 +56,9 @@ public class Winscreen{
t.scheduleTask(new Timer.Task() { t.scheduleTask(new Timer.Task() {
@Override @Override
public void run() { public void run() {
/*if(win.getY() < Gdx.graphics.getHeight()*0.8) /*if(win.getY() < GAME_WORLD_HEIGHT*0.8)
movement = true; movement = true;
else if(win.getY() > Gdx.graphics.getHeight() * 0.7) else if(win.getY() > GAME_WORLD_HEIGHT * 0.7)
movement = false; movement = false;
if(movement) if(movement)
win.setY(win.getY() + 3); win.setY(win.getY() + 3);

Loading…
Cancel
Save