X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2Fmobs%2FFallingGravel.java;h=fb567049394d79329a7ced59fb7a770c1224f2e3;hb=17c1be4c02b27fefa1bf6abd0547ac7e9743d493;hp=f30faefb4375e55715f921332f74d2bada5c19d9;hpb=0a855ca3c1d0c84de41a928cc99fd8544a933015;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java index f30faef..fb56704 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java @@ -2,18 +2,33 @@ package ru.deadsoftware.cavedroid.game.mobs; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavedroid.game.GameItems; +import org.jetbrains.annotations.NotNull; import ru.deadsoftware.cavedroid.misc.Assets; +import static ru.deadsoftware.cavedroid.GameScreen.GP; + +/** + * Falling gravel is actually a mob, that spawns in place of gravel when there is no block under it, + * falls down to the next block and becomes a block of gravel again. + */ public class FallingGravel extends Mob { + /** + * Creates a FallingGravel mob at coordinates + * @param x X in pixels + * @param y Y in pixels + */ public FallingGravel(float x, float y) { - super(x, y, 16, 16, 0); - mov = new Vector2(0, 1); + super(x, y, 16, 16, Direction.LEFT, Type.GRAVEL); + move = new Vector2(0, 1); } @Override public void ai() { + if (move.isZero()) { + GP.world.setForeMap(getMapX(), getMiddleMapY(), 11); + kill(); + } } @Override @@ -21,13 +36,8 @@ public class FallingGravel extends Mob { } @Override - public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(Assets.blockTex[GameItems.getBlock(11).getTex()], x, y); - } - - @Override - public int getType() { - return 11; + public void draw(@NotNull SpriteBatch spriteBatch, float x, float y) { + spriteBatch.draw(Assets.gravelSprite, x, y); } }