summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4ae2584)
raw | patch | inline | side by side (parent: 4ae2584)
author | fred-boy <fred-boy@protonmail.com> | |
Tue, 24 Apr 2018 19:47:58 +0000 (02:47 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Tue, 24 Apr 2018 19:47:58 +0000 (02:47 +0700) |
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index 6aef57907900c725b99ed2a0e0b264a15d43b00e..29b3d3b8a39b6a1efcb9aaa805e5e4cf3657c2fd 100644 (file)
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
+import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TimeUtils;
import ru.deadsoftware.cavecraft.*;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
+import ru.deadsoftware.cavecraft.game.mobs.Pig;
import ru.deadsoftware.cavecraft.game.objects.Player;
import java.io.Serializable;
world.generate(1024,256);
player = new Player(world.getSpawnPoint());
mobs = new ArrayList<Mob>();
+ for (int i=0; i<16; i++) {
+ mobs.add(new Pig(i*256, 128&16, this));
+ }
physics = new GamePhysics(this);
if (!CaveGame.TOUCH) ctrlMode = 1;
if (CaveGame.TOUCH) {
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java
index c52e78ff47dac0b895b4586182375464027d0f72..61ab375a7a10f310fb89e74ef1afd1733f0be873 100644 (file)
import com.badlogic.gdx.utils.Array;
import ru.deadsoftware.cavecraft.Assets;
-public abstract class Mob {
+import java.io.Serializable;
+
+public abstract class Mob implements Serializable{
public static int ANIM_SPEED = 6;
public static int ANIMATION = 0;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java
index 0400be0196d03990480f60261d4ba523fd8b65b6..7b922381c69d3f2c4fe172c5d479444104089cf3 100644 (file)
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import ru.deadsoftware.cavecraft.Assets;
-import ru.deadsoftware.cavecraft.game.GameWorld;
+import ru.deadsoftware.cavecraft.game.GameProc;
public class Pig extends Mob{
- private GameWorld world;
+ private GameProc gameProc;
- public Pig(int x, int y, GameWorld world) {
- this.world = world;
+ public Pig(int x, int y, GameProc gameProc) {
+ this.gameProc = gameProc;
position = new Vector2(x, y);
moveX = new Vector2(0, 0);
moveY = new Vector2(0, 0);
@Override
public void ai() {
- if (canJump && position.x>16 && position.x<(world.getWidth()-1)*16 &&
- world.getForeMap((int)(position.x/16)+(dir*2-1), (int)((position.y+height)/16))>0 &&
- world.getForeMap((int)(position.x/16)+(dir*2-1), (int)((position.y)/16))==0)
+ if (canJump && position.x>16 && position.x<(gameProc.world.getWidth()-1)*16 &&
+ gameProc.world.getForeMap((int)(position.x/16)+(dir*2-1), (int)((position.y+height)/16))>0 &&
+ gameProc.world.getForeMap((int)(position.x/16)+(dir*2-1), (int)((position.y)/16))==0)
moveY.add(0, -8);
if (MathUtils.randomBoolean(.0001f)) dir++;
if (dir>1) dir = 0;