1 package ru
.deadsoftware
.cavedroid
.game
.mobs
;
3 import com
.badlogic
.gdx
.Gdx
;
4 import com
.badlogic
.gdx
.graphics
.Texture
;
5 import com
.badlogic
.gdx
.graphics
.g2d
.SpriteBatch
;
6 import com
.badlogic
.gdx
.math
.Vector2
;
7 import ru
.deadsoftware
.cavedroid
.game
.GameItemsHolder
;
8 import ru
.deadsoftware
.cavedroid
.game
.world
.GameWorld
;
9 import ru
.deadsoftware
.cavedroid
.misc
.Assets
;
11 import javax
.annotation
.CheckForNull
;
14 * Falling gravel is actually a mob, that spawns in place of gravel when there is no block under it,
15 * falls down to the next block and becomes a block of gravel again.
17 public class FallingGravel
extends Mob
{
19 private static final String TAG
= "FallingGravel";
22 * Creates a FallingGravel mob at coordinates
24 * @param x X in pixels
25 * @param y Y in pixels
27 public FallingGravel(float x
, float y
) {
28 super(x
, y
, 16, 16, Direction
.LEFT
, Type
.GRAVEL
, Integer
.MAX_VALUE
);
29 mVelocity
= new Vector2(0, 1);
33 public float getSpeed() {
43 public void ai(GameWorld gameWorld
, GameItemsHolder gameItemsHolder
, float delta
) {
44 if (mVelocity
.isZero()) {
45 gameWorld
.setForeMap(getMapX(), getMiddleMapY(), gameItemsHolder
.getBlock("gravel"));
51 public void changeDir() {
55 public void draw(SpriteBatch spriteBatch
, float x
, float y
, float delta
) {
56 @CheckForNull final Texture texture
= Assets
.blockTextures
.get("gravel");
58 if (texture
== null) {
59 Gdx
.app
.error(TAG
, "Couldn't draw: texture not found");
64 spriteBatch
.draw(texture
, x
, y
);