DEADSOFTWARE

Some mobs refactor
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / mobs / FallingGravel.java
1 package ru.deadsoftware.cavedroid.game.mobs;
3 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 import com.badlogic.gdx.math.Vector2;
5 import ru.deadsoftware.cavedroid.game.GameItems;
6 import ru.deadsoftware.cavedroid.game.world.GameWorld;
8 /**
9 * Falling gravel is actually a mob, that spawns in place of gravel when there is no block under it,
10 * falls down to the next block and becomes a block of gravel again.
11 */
12 public class FallingGravel extends Mob {
14 /**
15 * Creates a FallingGravel mob at coordinates
16 *
17 * @param x X in pixels
18 * @param y Y in pixels
19 */
20 public FallingGravel(float x, float y) {
21 super(x, y, 16, 16, Direction.LEFT, Type.GRAVEL);
22 mVelocity = new Vector2(0, 1);
23 }
25 @Override
26 public float getSpeed() {
27 return 0;
28 }
30 @Override
31 public void jump() {
32 // no-op
33 }
35 @Override
36 public void ai(GameWorld gameWorld, float delta) {
37 if (mVelocity.isZero()) {
38 gameWorld.setForeMap(getMapX(), getMiddleMapY(), 11);
39 kill();
40 }
41 }
43 @Override
44 public void changeDir() {
45 }
47 @Override
48 public void draw(SpriteBatch spriteBatch, float x, float y, float delta) {
49 spriteBatch.draw(GameItems.getBlockTex(11), x, y);
50 }
52 }