DEADSOFTWARE

Nonnull by default
[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.misc.Assets;
7 import static ru.deadsoftware.cavedroid.GameScreen.GP;
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 * @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 move = new Vector2(0, 1);
23 }
25 @Override
26 public void ai() {
27 if (move.isZero()) {
28 GP.world.setForeMap(getMapX(), getMiddleMapY(), 11);
29 kill();
30 }
31 }
33 @Override
34 public void changeDir() {
35 }
37 @Override
38 public void draw(SpriteBatch spriteBatch, float x, float y) {
39 spriteBatch.draw(Assets.gravelSprite, x, y);
40 }
42 }