GammelJan 6 years ago
parent c71591876b
commit 196064b3a9

@ -9,6 +9,7 @@ import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx; 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.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
@ -19,6 +20,7 @@ import model.Projectile;
import view.Gamescreen; import view.Gamescreen;
import view.Levelscreen; import view.Levelscreen;
import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.viewport.FitViewport;
import view.Titlescreen; import view.Titlescreen;
import view.Winscreen; import view.Winscreen;
@ -37,6 +39,9 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
Timer stepTimer; Timer stepTimer;
Level level; Level level;
OrthographicCamera camera;
FitViewport fitViewport;
@Override @Override
public void create(){ public void create(){
@ -48,6 +53,9 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
batch = new SpriteBatch(); batch = new SpriteBatch();
Gdx.input.setInputProcessor(this); Gdx.input.setInputProcessor(this);
camera = new OrthographicCamera(1280, 720);
fitViewport = new FitViewport(1280, 720, camera);
level = new Level(new Goal(700,400,200,80), new Projectile(0,0,0),200,200); level = new Level(new Goal(700,400,200,80), new Projectile(0,0,0),200,200);
stepTimer = new Timer(); stepTimer = new Timer();
@ -73,6 +81,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
public void render(){ public void render(){
Gdx.gl.glClearColor(1f, 1f, 1f, 1f); Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
fitViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
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);

Loading…
Cancel
Save