diff --git a/core/assets/animplay.png b/core/assets/animplay.png new file mode 100644 index 0000000..881f12f Binary files /dev/null and b/core/assets/animplay.png differ diff --git a/core/src/com/dungeoncrawler/control/Controller.java b/core/src/com/dungeoncrawler/control/Controller.java index 9ef33a8..8c9180b 100644 --- a/core/src/com/dungeoncrawler/control/Controller.java +++ b/core/src/com/dungeoncrawler/control/Controller.java @@ -54,12 +54,12 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ } if(keycode == Input.Keys.UP){ - movementY = 4f; + movementY = 3f; v.render(batch, movementX, movementY); } if(keycode == Input.Keys.DOWN){ - movementY = -4f; + movementY = -3f; v.render(batch, movementX, movementY); } return true; @@ -69,10 +69,14 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ public boolean keyUp(int keycode) { if(keycode == Input.Keys.LEFT || keycode == Input.Keys.RIGHT){ movementX = 0f; + v.trechtsstop(); + v.tlinksstop(); } if(keycode == Input.Keys.DOWN || keycode == Input.Keys.UP){ movementY = 0f; + v.tobenstop(); + v.tuntenstop(); } return true; } diff --git a/core/src/com/dungeoncrawler/view/View.java b/core/src/com/dungeoncrawler/view/View.java index 9473569..cdc6e9f 100644 --- a/core/src/com/dungeoncrawler/view/View.java +++ b/core/src/com/dungeoncrawler/view/View.java @@ -5,6 +5,8 @@ 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; +import com.badlogic.gdx.utils.Timer; +import com.badlogic.gdx.graphics.g2d.TextureRegion; public class View { Texture b; @@ -13,14 +15,21 @@ public class View { Sprite button; Sprite title; Sprite player; + int frame = 0; + int zeile = 0; + TextureRegion[][] regions; + Timer tunten; + Timer toben; + Timer tlinks; + Timer trechts; public View() { b = new Texture("Button.png"); t = new Texture("Title.png"); - p = new Texture("Player.png"); + p = new Texture("animplay.png"); button = new Sprite(b); title = new Sprite(t); - player = new Sprite(p); + float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); float wc = w/2; @@ -28,8 +37,86 @@ public class View { title.setY(h - 200); button.setX(wc - (button.getWidth()/2)); button.setY(400); + regions = TextureRegion.split(p, 32, 32); + player = new Sprite(regions[0][2]); player.setX(200); player.setY(200); + tunten = new Timer(); + toben = new Timer(); + tlinks = new Timer(); + trechts = new Timer(); + + tunten.scheduleTask(new Timer.Task() { + @Override + public void run() { + zeile = 2; + + if(frame == 9){ + frame = 0; + } + else{ + frame++; + } + + player.setRegion(regions[zeile][frame]); + + } + },0,1/5f); + tunten.stop(); + toben.scheduleTask(new Timer.Task() { + @Override + public void run() { + zeile = 2; + + if(frame == 9){ + frame = 0; + } + else{ + frame++; + } + + player.setRegion(regions[zeile][frame]); + + } + }, 0,1/5f); + toben.stop(); + tlinks.scheduleTask(new Timer.Task() { + @Override + public void run() { + zeile = 2; + + if(frame == 9){ + frame = 0; + } + else{ + frame++; + } + + player.setRegion(regions[zeile][frame]); + + } + }, 0,1/5f); + tlinks.stop(); + trechts.scheduleTask(new Timer.Task() { + @Override + public void run() { + zeile = 2; + + if(frame == 9){ + frame = 0; + } + else{ + frame++; + } + + player.setRegion(regions[zeile][frame]); + + } + }, 0,1/5f); + trechts.stop(); + + + } @@ -38,6 +125,19 @@ public class View { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); player.setX(player.getX()+x); player.setY(player.getY()+y); + if(x == 3f){ + trechts.start(); + } + if(x == -3f){ + tlinks.start(); + } + if(y == 3f){ + toben.start(); + } + if(y == -3f){ + tunten.start(); + } + batch.begin(); title.draw(batch); button.draw(batch); @@ -47,5 +147,17 @@ public class View { - -} \ No newline at end of file + public void tuntenstop(){ + tunten.stop(); + frame = 0;} + public void tobenstop(){ + toben.stop(); + frame = 0;} + public void tlinksstop(){ + tlinks.stop(); + frame = 0;} + public void trechtsstop(){ + trechts.stop(); + frame = 0;} + + }