master
Jonathan Hager 6 years ago
commit 05f8d862dc

@ -41,7 +41,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
int levelAmount; int levelAmount;
SpriteBatch batch; SpriteBatch batch;
Timer stepTimer; Timer stepTimer;
Level level; Level[] level;
int currentLevel; int currentLevel;
OrthographicCamera camera; OrthographicCamera camera;
@ -69,29 +69,33 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
viewport.apply(); viewport.apply();
camera.position.set(GAME_WORLD_WIDTH/2, GAME_WORLD_HEIGHT/2, 0); camera.position.set(GAME_WORLD_WIDTH/2, GAME_WORLD_HEIGHT/2, 0);
level = new Level[10];
currentLevel = 0;
level[0] = new Level(new Goal(500,200,150,50, 0.2f), new Projectile(0,0,0),200,200);
stepTimer = new Timer(); stepTimer = new Timer();
stepTimer.scheduleTask(new Timer.Task() { stepTimer.scheduleTask(new Timer.Task() {
@Override @Override
public void run() { public void run() {
if(gs != null){ if(gs != null){
if(level.getProjectile().getxPos() > Gdx.graphics.getWidth() || level.getProjectile().getxPos() < 0 || level.getProjectile().getyPos() < 0){ if(level[currentLevel].getProjectile().getxPos() > Gdx.graphics.getWidth() || level[currentLevel].getProjectile().getxPos() < 0 || level[currentLevel].getProjectile().getyPos() < 0){
gs.step(level); gs.step(level[currentLevel]);
level.reset(); level[currentLevel].reset();
gs.dispose(); gs.dispose();
stepTimer.stop(); stepTimer.stop();
gs = null; gs = null;
ws = new Winscreen(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, false); ws = new Winscreen(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, false);
} }
else{ else{
level.step(); level[currentLevel].step();
gs.step(level); gs.step(level[currentLevel]);
for(Rectangle rect : gs.getGoalRects()){ for(Rectangle rect : gs.getGoalRects()){
if(Intersector.overlaps(gs.getProjectileCirc(), rect)){ if(Intersector.overlaps(gs.getProjectileCirc(), rect)){
if(rect.getHeight() == 1){ if(rect.getHeight() == 1){
level.horizontalCollision(); level[currentLevel].horizontalCollision();
} }
else if(rect.getWidth() == 1){ else if(rect.getWidth() == 1){
level.verticalCollision(); level[currentLevel].verticalCollision();
} }
break; break;
} }
@ -123,7 +127,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
currentLevel = ls.getSelectedLevel(); currentLevel = ls.getSelectedLevel();
} }
else if(gs != null){ else if(gs != null){
gs.render(batch, level); gs.render(batch, level[currentLevel]);
if(gs.getWin()){ if(gs.getWin()){
gs.dispose(); gs.dispose();
stepTimer.stop(); stepTimer.stop();
@ -179,8 +183,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
} }
} }
else if(gs != null){ else if(gs != null){
if(!level.released()){ if(!level[currentLevel].released()){
level.projectileReleased(); level[currentLevel].projectileReleased();
} }
} }
else if(ws != null){ else if(ws != null){

Loading…
Cancel
Save