archer graphic added - no function yet

master
GammelJan 6 years ago
parent 26a486a8f4
commit d2360cb338

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

@ -13,27 +13,31 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.dungeoncrawler.view.View; import com.dungeoncrawler.view.View;
import com.dungeoncrawler.model.Dungeon; import com.dungeoncrawler.model.Dungeon;
import com.dungeoncrawler.model.entities.Player; import com.dungeoncrawler.model.entities.Player;
import com.dungeoncrawler.model.entities.Archer;
public class Controller extends ApplicationAdapter implements InputProcessor{ public class Controller extends ApplicationAdapter implements InputProcessor{
SpriteBatch batch; SpriteBatch batch;
Dungeon d; Dungeon d;
View v; View v;
Player p; Player p;
Archer a;
float movementX = 0f; float movementX = 0f;
float movementY = 0f; float movementY = 0f;
@Override @Override
public void create(){ public void create(){
batch = new SpriteBatch(); batch = new SpriteBatch();
v = new View(); v = new View();
p = new Player(0,0,0); p = new Player(0,0,1);
d = new Dungeon(p); d = new Dungeon(p);
a = new Archer(500, 200, 1);
Gdx.input.setInputProcessor(this); Gdx.input.setInputProcessor(this);
} }
@Override @Override
public void render(){ public void render(){
v.render(batch, movementX ,movementY); v.render(batch, movementX ,movementY, a.getxPos(), a.getyPos());
} }
@Override @Override
@ -45,23 +49,26 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
public boolean keyDown(int keycode) { public boolean keyDown(int keycode) {
if(keycode == Input.Keys.LEFT){ if(keycode == Input.Keys.LEFT){
movementX = -3f; movementX = -3f;
v.render(batch, movementX, movementY); v.render(batch, movementX, movementY, a.getxPos(), a.getyPos());
} }
if(keycode == Input.Keys.RIGHT){ if(keycode == Input.Keys.RIGHT){
movementX = 3f; movementX = 3f;
v.render(batch, movementX, movementY); v.render(batch, movementX, movementY, a.getxPos(), a.getyPos());
} }
if(keycode == Input.Keys.UP){ if(keycode == Input.Keys.UP){
movementY = 3f; movementY = 2f;
v.render(batch, movementX, movementY); v.render(batch, movementX, movementY, a.getxPos(), a.getyPos());
} }
if(keycode == Input.Keys.DOWN){ if(keycode == Input.Keys.DOWN){
movementY = -3f; movementY = -2f;
v.render(batch, movementX, movementY); v.render(batch, movementX, movementY, a.getxPos(), a.getyPos());
} }
if(keycode == Input.Keys.W){
}
return true; return true;
} }

@ -14,4 +14,6 @@ public class Archer extends Entity{
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
} }
} }

@ -24,4 +24,6 @@ public class Player extends Entity {
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
} }
} }

@ -12,9 +12,11 @@ public class View {
Texture b; Texture b;
Texture t; Texture t;
Texture p; Texture p;
Texture a;
Sprite button; Sprite button;
Sprite title; Sprite title;
Sprite player; Sprite player;
Sprite archer;
int frame = 0; int frame = 0;
int zeile = 0; int zeile = 0;
TextureRegion[][] regions; TextureRegion[][] regions;
@ -27,8 +29,10 @@ public class View {
b = new Texture("Button.png"); b = new Texture("Button.png");
t = new Texture("Title.png"); t = new Texture("Title.png");
p = new Texture("animplay.png"); p = new Texture("animplay.png");
a = new Texture("Archer.png");
button = new Sprite(b); button = new Sprite(b);
title = new Sprite(t); title = new Sprite(t);
archer = new Sprite(a);
float w = Gdx.graphics.getWidth(); float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight(); float h = Gdx.graphics.getHeight();
@ -129,12 +133,13 @@ public class View {
} }
public void render (SpriteBatch batch, float x, float y) { public void render (SpriteBatch batch, float x, float y, int archerX, int archerY) {
Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
player.setX(player.getX()+x); player.setX(player.getX()+x);
player.setY(player.getY()+y); player.setY(player.getY()+y);
archer.setX(archerX);
archer.setY(archerY);
if(x == 3f){ if(x == 3f){
trechts.start(); trechts.start();
if(player.isFlipX() == true){ if(player.isFlipX() == true){
@ -161,6 +166,7 @@ public class View {
title.draw(batch); title.draw(batch);
button.draw(batch); button.draw(batch);
player.draw(batch); player.draw(batch);
archer.draw(batch);
batch.end(); batch.end();
} }

Loading…
Cancel
Save