DEADSOFTWARE

Refactor physics
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / mobs / FallingSand.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 org.jetbrains.annotations.NotNull;
6 import ru.deadsoftware.cavedroid.misc.Assets;
8 import static ru.deadsoftware.cavedroid.GameScreen.GP;
10 /**
11 * Falling sand is actually a mob, that spawns in place of gravel when there is no block under it,
12 * falls down to the next block and becomes a block of sand again.
13 */
14 public class FallingSand extends Mob {
16 /**
17 * Creates a FallingSand mob at coordinates
18 * @param x X in pixels
19 * @param y Y in pixels
20 */
21 public FallingSand(float x, float y) {
22 super(x, y, 16, 16, Direction.LEFT, Type.SAND);
23 move = new Vector2(0, 1);
24 }
26 @Override
27 public void ai() {
28 if (move.isZero()) {
29 GP.world.setForeMap(getMapX(), getMiddleMapY(), 10);
30 kill();
31 }
32 }
34 @Override
35 public void changeDir() {
36 }
38 @Override
39 public void draw(@NotNull SpriteBatch spriteBatch, float x, float y) {
40 spriteBatch.draw(Assets.sandSprite, x, y);
41 }
43 }