Jonathan Hager 6 years ago
parent 4d0534dbc6
commit efc6f03ea8

@ -6,11 +6,13 @@ import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.throwgame.main.Main; import com.throwgame.main.Main;
import controller.Controller;
public class AndroidLauncher extends AndroidApplication { public class AndroidLauncher extends AndroidApplication {
@Override @Override
protected void onCreate (Bundle savedInstanceState) { protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new Main(), config); initialize(new Controller(), config);
} }
} }

@ -30,6 +30,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
int levelAmount; int levelAmount;
SpriteBatch batch; SpriteBatch batch;
Timer stepTimer; Timer stepTimer;
Level level;
@Override @Override
public void create(){ public void create(){
@ -40,11 +41,15 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
batch = new SpriteBatch(); batch = new SpriteBatch();
Gdx.input.setInputProcessor(this); Gdx.input.setInputProcessor(this);
level = new Level(new Goal(500,500,200,150), new Projectile(100,100,0),400,400);
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(ls != null) {
level.step();
}
} }
}, 0, 0.1f); }, 0, 0.1f);
} }
@ -56,7 +61,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
batch.begin(); batch.begin();
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);
else if(gs != null) gs.render(batch, new Level(new Goal(500,500,200,150), new Projectile(100,100,0),50,50)); else if(gs != null) gs.render(batch, level);
batch.end(); batch.end();
} }
@ -99,12 +104,10 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
else{ else{
ls.dispose(); ls.dispose();
ls = null; ls = null;
gs = new Gamescreen(new Level(new Goal(500,500,200,150), new Projectile(100,100,0),50,50)); gs = new Gamescreen(level);
} }
} }
else if(gs != null){ else if(gs != null){
gs = null;
ls = new Levelscreen(levelAmount);
} }
return true; return true;
} }

Loading…
Cancel
Save