diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java
index 07cd8cdd84e3ddf8249be1964681b2a422c09b63..f41da96872c12aa7fc32ce6dffc885822d13935d 100644 (file)
package ru.deadsoftware.cavedroid.game.mobs;
package ru.deadsoftware.cavedroid.game.mobs;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavedroid.game.GameItems;
+import ru.deadsoftware.cavedroid.game.GameItemsHolder;
import ru.deadsoftware.cavedroid.game.world.GameWorld;
import ru.deadsoftware.cavedroid.game.world.GameWorld;
+import ru.deadsoftware.cavedroid.misc.Assets;
+
+import javax.annotation.CheckForNull;
/**
/**
*/
public class FallingSand extends Mob {
*/
public class FallingSand extends Mob {
+ private static final String TAG = "FallingSand";
+
/**
* Creates a FallingSand mob at coordinates
*
/**
* Creates a FallingSand mob at coordinates
*
* @param y Y in pixels
*/
public FallingSand(float x, float y) {
* @param y Y in pixels
*/
public FallingSand(float x, float y) {
- super(x, y, 16, 16, Direction.LEFT, Type.SAND);
+ super(x, y, 16, 16, Direction.LEFT, Type.SAND, Integer.MAX_VALUE);
mVelocity = new Vector2(0, 1);
}
@Override
mVelocity = new Vector2(0, 1);
}
@Override
- public void ai(GameWorld gameWorld, float delta) {
+ public float getSpeed() {
+ return 0;
+ }
+
+ @Override
+ public void jump() {
+ // no-op
+ }
+
+ @Override
+ public void ai(GameWorld gameWorld, GameItemsHolder gameItemsHolder, float delta) {
if (mVelocity.isZero()) {
if (mVelocity.isZero()) {
- gameWorld.setForeMap(getMapX(), getMiddleMapY(), 10);
+ gameWorld.setForeMap(getMapX(), getUpperMapY(), gameItemsHolder.getBlock("sand"));
kill();
}
}
kill();
}
}
@Override
public void draw(SpriteBatch spriteBatch, float x, float y, float delta) {
@Override
public void draw(SpriteBatch spriteBatch, float x, float y, float delta) {
- spriteBatch.draw(GameItems.getBlockTex(10), x, y);
+ @CheckForNull final Texture texture = Assets.blockTextures.get("sand");
+
+ if (texture == null) {
+ Gdx.app.error(TAG, "Couldn't draw: texture not found");
+ kill();
+ return;
+ }
+
+ spriteBatch.draw(texture, x, y);
}
}
}
}