diff --git a/core/src/com/dungeoncrawler/control/Controller.java b/core/src/com/dungeoncrawler/control/Controller.java index 56b4a12..9115f4d 100644 --- a/core/src/com/dungeoncrawler/control/Controller.java +++ b/core/src/com/dungeoncrawler/control/Controller.java @@ -4,15 +4,18 @@ * and open the template in the editor. */ package com.dungeoncrawler.control; + import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.InputProcessor; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.dungeoncrawler.view.View; import com.dungeoncrawler.model.Dungeon; import com.dungeoncrawler.model.entities.Player; public class Controller extends ApplicationAdapter implements InputProcessor{ + SpriteBatch batch; Dungeon d; View v; Player p; @@ -21,6 +24,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ @Override public void create(){ + batch = new SpriteBatch(); v = new View(); p = new Player(0,0,0); d = new Dungeon(p); @@ -29,12 +33,12 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ @Override public void render(){ - v.render(); + v.render(batch); } @Override public void dispose () { - v.dispose(); + batch.dispose(); } @Override diff --git a/core/src/com/dungeoncrawler/view/View.java b/core/src/com/dungeoncrawler/view/View.java index fb18b23..349471e 100644 --- a/core/src/com/dungeoncrawler/view/View.java +++ b/core/src/com/dungeoncrawler/view/View.java @@ -1,14 +1,12 @@ package com.dungeoncrawler.view; -import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.Sprite; -public class View extends ApplicationAdapter { - SpriteBatch batch; +public class View { Texture b; Texture t; Texture p; @@ -16,10 +14,7 @@ public class View extends ApplicationAdapter { Sprite title; Sprite player; - - @Override - public void create () { - batch = new SpriteBatch(); + public View() { b = new Texture("Button.png"); t = new Texture("Title.png"); p = new Texture("Player.png"); @@ -38,9 +33,10 @@ public class View extends ApplicationAdapter { } - public void render () { + public void render (SpriteBatch batch) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + batch.begin(); title.draw(batch); button.draw(batch); @@ -48,12 +44,6 @@ public class View extends ApplicationAdapter { batch.end(); } - - public void dispose () { - batch.dispose(); - - } - public void move(float x, float y){ player.setX(player.getX()+x); player.setY(player.getY()+y);