DEADSOFTWARE

e80f91b5e70987b2697fe9005a2d10d6e1841248
[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.GameItemsHolder;
7 import ru.deadsoftware.cavedroid.game.world.GameWorld;
9 /**
10 * Falling gravel is actually a mob, that spawns in place of gravel when there is no block under it,
11 * falls down to the next block and becomes a block of gravel again.
12 */
13 public class FallingGravel extends Mob {
15 /**
16 * Creates a FallingGravel mob at coordinates
17 *
18 * @param x X in pixels
19 * @param y Y in pixels
20 */
21 public FallingGravel(float x, float y) {
22 super(x, y, 16, 16, Direction.LEFT, Type.GRAVEL, Integer.MAX_VALUE);
23 mVelocity = new Vector2(0, 1);
24 }
26 @Override
27 public float getSpeed() {
28 return 0;
29 }
31 @Override
32 public void jump() {
33 // no-op
34 }
36 @Override
37 public void ai(GameWorld gameWorld, GameItemsHolder gameItemsHolder, float delta) {
38 if (mVelocity.isZero()) {
39 gameWorld.setForeMap(getMapX(), getMiddleMapY(), gameItemsHolder.getBlock("gravel"));
40 kill();
41 }
42 }
44 @Override
45 public void changeDir() {
46 }
48 @Override
49 public void draw(SpriteBatch spriteBatch, float x, float y, float delta) {
50 spriteBatch.draw(GameItems.getBlockTex(11), x, y);
51 }
53 }