diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
4 files changed, 58 insertions, 39 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/gfx/Animation.java b/core/src/ch/asynk/tankontank/engine/gfx/Animation.java index 742810c..595c0da 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/Animation.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/Animation.java @@ -2,11 +2,7 @@ package ch.asynk.tankontank.engine.gfx; import com.badlogic.gdx.utils.Disposable; -import ch.asynk.tankontank.engine.Pawn; - -public interface Animation extends Disposable +public interface Animation extends Disposable, Drawable { - public Pawn getPawn(); - public boolean animate(float delta); } diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/AnimationSequence.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/AnimationSequence.java index 9d5495a..4a111f3 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/animations/AnimationSequence.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/AnimationSequence.java @@ -3,8 +3,9 @@ package ch.asynk.tankontank.engine.gfx.animations; import java.util.ArrayList; import com.badlogic.gdx.utils.Pool; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.engine.gfx.Animation; public class AnimationSequence implements Animation, Pool.Poolable @@ -43,12 +44,6 @@ public class AnimationSequence implements Animation, Pool.Poolable animationSequencePool.free(this); } - @Override - public Pawn getPawn() - { - return animations.get(0).getPawn(); - } - public void addAnimation(Animation animation) { animations.add(animation); @@ -66,4 +61,16 @@ public class AnimationSequence implements Animation, Pool.Poolable return (animations.isEmpty()); } + + @Override + public void draw(Batch batch) + { + animations.get(0).draw(batch); + } + + @Override + public void drawDebug(ShapeRenderer debugShapes) + { + animations.get(0).drawDebug(debugShapes); + } } diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java index aa2e630..aafb943 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java @@ -2,12 +2,14 @@ package ch.asynk.tankontank.engine.gfx.animations; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Pool; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -import ch.asynk.tankontank.engine.Pawn; +import ch.asynk.tankontank.engine.gfx.Moveable; public class MoveToAnimation extends TimedAnimation { - private Pawn pawn; + private Moveable moveable; private float fromX; private float fromY; private float fromR; @@ -23,16 +25,16 @@ public class MoveToAnimation extends TimedAnimation } }; - public static MoveToAnimation get(Pawn pawn, Vector3 v, float duration) + public static MoveToAnimation get(Moveable moveable, Vector3 v, float duration) { - return get(pawn, v.x, v.y, v.z, duration); + return get(moveable, v.x, v.y, v.z, duration); } - public static MoveToAnimation get(Pawn pawn, float x, float y, float r, float duration) + public static MoveToAnimation get(Moveable moveable, float x, float y, float r, float duration) { MoveToAnimation a = moveToAnimationPool.obtain(); - a.pawn = pawn; + a.moveable = moveable; a.toX = x; a.toY = y; a.toR = r; @@ -43,12 +45,6 @@ public class MoveToAnimation extends TimedAnimation } @Override - public Pawn getPawn() - { - return pawn; - } - - @Override public void dispose() { moveToAnimationPool.free(this); @@ -57,9 +53,9 @@ public class MoveToAnimation extends TimedAnimation @Override protected void begin() { - fromX = pawn.getX(); - fromY = pawn.getY(); - fromR = pawn.getRotation(); + fromX = moveable.getX(); + fromY = moveable.getY(); + fromR = moveable.getRotation(); if (Math.abs(toR - fromR) <= 180.f) rDelta = (toR - fromR); @@ -81,8 +77,20 @@ public class MoveToAnimation extends TimedAnimation protected void update(float percent) { if (percent == 1f) - pawn.setPosition(toX, toY, (int) toR); + moveable.setPosition(toX, toY, (int) toR); else - pawn.setPosition(fromX + ((toX - fromX) * percent), fromY + ((toY - fromY) * percent), (fromR + (rDelta * percent))); + moveable.setPosition(fromX + ((toX - fromX) * percent), fromY + ((toY - fromY) * percent), (fromR + (rDelta * percent))); + } + + @Override + public void draw(Batch batch) + { + moveable.draw(batch); + } + + @Override + public void drawDebug(ShapeRenderer debugShapes) + { + moveable.drawDebug(debugShapes); } } diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/RunnableAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/RunnableAnimation.java index 24b1e4b..4f81f33 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/animations/RunnableAnimation.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/RunnableAnimation.java @@ -1,14 +1,16 @@ package ch.asynk.tankontank.engine.gfx.animations; import com.badlogic.gdx.utils.Pool; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -import ch.asynk.tankontank.engine.Pawn; +import ch.asynk.tankontank.engine.gfx.Moveable; import ch.asynk.tankontank.engine.gfx.Animation; public class RunnableAnimation implements Animation, Pool.Poolable { private Runnable runnable; - private Pawn pawn; + private Moveable moveable; private boolean ran; private static final Pool<RunnableAnimation> runnableAnimationPool = new Pool<RunnableAnimation>() { @@ -18,11 +20,11 @@ public class RunnableAnimation implements Animation, Pool.Poolable } }; - public static RunnableAnimation get(Pawn pawn, Runnable runnable) + public static RunnableAnimation get(Moveable moveable, Runnable runnable) { RunnableAnimation a = runnableAnimationPool.obtain(); a.runnable = runnable; - a.pawn = pawn; + a.moveable = moveable; return a; } @@ -39,12 +41,6 @@ public class RunnableAnimation implements Animation, Pool.Poolable } @Override - public Pawn getPawn() - { - return pawn; - } - - @Override public boolean animate(float delta) { if (ran) return true; @@ -56,4 +52,16 @@ public class RunnableAnimation implements Animation, Pool.Poolable return true; } + + @Override + public void draw(Batch batch) + { + moveable.draw(batch); + } + + @Override + public void drawDebug(ShapeRenderer debugShapes) + { + moveable.drawDebug(debugShapes); + } } |