movement works

master
GammelJan 6 years ago
parent 1e58fc09b3
commit a532be9a46

@ -33,7 +33,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
@Override
public void render(){
v.render(batch);
v.render(batch, movementX ,movementY);
}
@Override
@ -45,32 +45,36 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
public boolean keyDown(int keycode) {
if(keycode == Input.Keys.LEFT){
movementX = -3f;
v.move(movementX, movementY);
System.out.println("EY");
v.render(batch, movementX, movementY);
}
if(keycode == Input.Keys.RIGHT){
movementX = 3f;
v.move(movementX, movementY);
v.render(batch, movementX, movementY);
}
if(keycode == Input.Keys.UP){
movementY = 3f;
v.move(movementX, movementY);
movementY = 4f;
v.render(batch, movementX, movementY);
}
if(keycode == Input.Keys.DOWN){
movementY = -3f;
v.move(movementX, movementY);
movementY = -4f;
v.render(batch, movementX, movementY);
}
return true;
}
@Override
public boolean keyUp(int i) {
movementY = 0f;
movementX = 0f;
return true;
public boolean keyUp(int keycode) {
if(keycode == Input.Keys.LEFT || keycode == Input.Keys.RIGHT){
movementX = 0f;
}
if(keycode == Input.Keys.DOWN || keycode == Input.Keys.UP){
movementY = 0f;
}
return true;
}
@Override

@ -33,10 +33,11 @@ public class View {
}
public void render (SpriteBatch batch) {
public void render (SpriteBatch batch, float x, float y) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
player.setX(player.getX()+x);
player.setY(player.getY()+y);
batch.begin();
title.draw(batch);
button.draw(batch);
@ -44,11 +45,7 @@ public class View {
batch.end();
}
public void move(float x, float y){
player.setX(player.getX()+x);
player.setY(player.getY()+y);
System.out.println("PRESS");
}
}

Loading…
Cancel
Save