|
|
|
@ -10,13 +10,9 @@ import com.badlogic.gdx.Gdx;
|
|
|
|
import com.badlogic.gdx.InputProcessor;
|
|
|
|
import com.badlogic.gdx.InputProcessor;
|
|
|
|
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.graphics.Texture;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|
|
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|
|
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
|
|
|
|
|
|
import model.Goal;
|
|
|
|
|
|
|
|
import model.Level;
|
|
|
|
import model.Level;
|
|
|
|
import model.Projectile;
|
|
|
|
|
|
|
|
import view.Gamescreen;
|
|
|
|
import view.Gamescreen;
|
|
|
|
import view.Levelscreen;
|
|
|
|
import view.Levelscreen;
|
|
|
|
|
|
|
|
|
|
|
|
@ -24,8 +20,6 @@ import com.badlogic.gdx.math.Intersector;
|
|
|
|
import com.badlogic.gdx.math.Rectangle;
|
|
|
|
import com.badlogic.gdx.math.Rectangle;
|
|
|
|
import com.badlogic.gdx.utils.Timer;
|
|
|
|
import com.badlogic.gdx.utils.Timer;
|
|
|
|
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
|
|
|
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
|
|
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
|
|
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
|
|
|
import view.Titlescreen;
|
|
|
|
import view.Titlescreen;
|
|
|
|
import view.Winscreen;
|
|
|
|
import view.Winscreen;
|
|
|
|
@ -48,6 +42,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
SpriteBatch batch;
|
|
|
|
SpriteBatch batch;
|
|
|
|
Timer stepTimer;
|
|
|
|
Timer stepTimer;
|
|
|
|
Level level;
|
|
|
|
Level level;
|
|
|
|
|
|
|
|
int currentLevel;
|
|
|
|
|
|
|
|
|
|
|
|
OrthographicCamera camera;
|
|
|
|
OrthographicCamera camera;
|
|
|
|
Viewport viewport;
|
|
|
|
Viewport viewport;
|
|
|
|
@ -62,6 +57,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
gs = null;
|
|
|
|
gs = null;
|
|
|
|
ws = null;
|
|
|
|
ws = null;
|
|
|
|
levelAmount = 10;
|
|
|
|
levelAmount = 10;
|
|
|
|
|
|
|
|
currentLevel = -1;
|
|
|
|
batch = new SpriteBatch();
|
|
|
|
batch = new SpriteBatch();
|
|
|
|
Gdx.input.setInputProcessor(this);
|
|
|
|
Gdx.input.setInputProcessor(this);
|
|
|
|
|
|
|
|
|
|
|
|
@ -73,8 +69,6 @@ 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(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
|
|
|
|
@ -124,7 +118,10 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
batch.begin();
|
|
|
|
batch.begin();
|
|
|
|
batch.setProjectionMatrix(camera.combined);
|
|
|
|
batch.setProjectionMatrix(camera.combined);
|
|
|
|
if(ts != null) ts.render(batch);
|
|
|
|
if(ts != null) ts.render(batch);
|
|
|
|
else if(ls != null) ls.render(batch);
|
|
|
|
else if(ls != null){
|
|
|
|
|
|
|
|
ls.render(batch);
|
|
|
|
|
|
|
|
currentLevel = ls.getSelectedLevel();
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(gs != null){
|
|
|
|
else if(gs != null){
|
|
|
|
gs.render(batch, level);
|
|
|
|
gs.render(batch, level);
|
|
|
|
if(gs.getWin()){
|
|
|
|
if(gs.getWin()){
|
|
|
|
@ -177,8 +174,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
ls.dispose();
|
|
|
|
ls.dispose();
|
|
|
|
ls = null;
|
|
|
|
ls = null;
|
|
|
|
level = new Level(new Goal(500,200,150,50, 0.2f), new Projectile(0,0,0),200,200);
|
|
|
|
gs = new Gamescreen(level[currentLevel], GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
|
|
|
|
gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
|
|
|
|
|
|
|
|
stepTimer.start();
|
|
|
|
stepTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -192,13 +188,12 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
ls = new Levelscreen(levelAmount, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
|
|
|
|
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){
|
|
|
|
level = new Level(new Goal(500,200,150,50, 0.2f), new Projectile(0,0,0),200,200);
|
|
|
|
gs = new Gamescreen(level[currentLevel], GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
|
|
|
|
gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
|
|
|
|
|
|
|
|
stepTimer.start();
|
|
|
|
stepTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
level = new Level(new Goal(500,200,150,50, 0.2f), new Projectile(0,0,0),200,200);
|
|
|
|
currentLevel++;
|
|
|
|
gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
|
|
|
|
gs = new Gamescreen(level[currentLevel], GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
|
|
|
|
stepTimer.start();
|
|
|
|
stepTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ws = null;
|
|
|
|
ws = null;
|
|
|
|
|