diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-25 00:06:01 +0200 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-25 00:06:01 +0200 | 
| commit | 357eddc4a412bb928787ab02f5e0f4c3caf74100 (patch) | |
| tree | 15b9f54a81f2889deba9d9e48f0f19b0c2f77427 /core/src/ch | |
| parent | 7dc1371623866537b615c3eda59ee7a124d6bc60 (diff) | |
| download | RustAndDust-357eddc4a412bb928787ab02f5e0f4c3caf74100.zip RustAndDust-357eddc4a412bb928787ab02f5e0f4c3caf74100.tar.gz | |
add engine/HeadedPawn
Diffstat (limited to 'core/src/ch')
| -rw-r--r-- | core/src/ch/asynk/tankontank/engine/HeadedPawn.java | 65 | 
1 files changed, 65 insertions, 0 deletions
| diff --git a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java new file mode 100644 index 0000000..36eb2a2 --- /dev/null +++ b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java @@ -0,0 +1,65 @@ +package ch.asynk.tankontank.engine; + +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; + +import ch.asynk.tankontank.engine.gfx.Image; + +import com.badlogic.gdx.math.Vector3; + +public abstract class HeadedPawn extends Pawn +{ +    private Image head; + +    public HeadedPawn(TextureRegion region, TextureRegion head, TextureAtlas atlas) +    { +        super(region, atlas); +        this.head = new Image(head); +    } + +    @Override +    public void dispose() +    { +        super.dispose(); +        head.dispose(); +    } + +    @Override +    public float getRotation() +    { +        return head.getRotation(); +    } + +    @Override +    public void translate(float dx, float dy) +    { +        super.translate(dx, dy); +        head.translate(dx, dy); +    } + +    @Override +    public void setPosition(float x, float y, float z) +    { +        super.setPosition(x, y); +        float cx = x + (getWidth() / 2f) - (head.getWidth() / 2f); +        float cy = y + (getHeight() / 2f) - (head.getHeight() / 2f); +        head.setPosition(cx, cy); +        head.setRotation(z); +    } + +    @Override +    public void draw(Batch batch) +    { +        head.draw(batch); +        super.draw(batch); +    } + +    @Override +    public void drawDebug(ShapeRenderer debugShapes) +    { +        head.drawDebug(debugShapes); +        super.drawDebug(debugShapes); +    } +} | 
