DEADSOFTWARE

Add mobs
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / mobs / Human.java
1 package ru.deadsoftware.cavecraft.game.mobs;
3 import com.badlogic.gdx.math.RandomXS128;
4 import com.badlogic.gdx.math.Rectangle;
5 import com.badlogic.gdx.math.Vector2;
6 import ru.deadsoftware.cavecraft.game.GameProc;
8 public class Human extends Mob{
10 private RandomXS128 rand = new RandomXS128();
11 private GameProc gameProc;
13 public Human(int x, int y, GameProc gameProc) {
14 this.gameProc = gameProc;
15 position = new Vector2(x, y);
16 moveX = new Vector2(0, 0);
17 moveY = new Vector2(0, 0);
18 width = 8;
19 height = 30;
20 dir = 1;
21 canJump = false;
22 }
24 @Override
25 public void ai() {
26 if (canJump && gameProc.world.getForeMap(
27 (int)(position.x/16)+(dir*2-1), (int)(position.y/16)+1)>0)
28 moveY.add(0, -8);
29 if (rand.nextInt(500)>490) dir++;
30 if (dir>1) dir = 0;
31 moveX.setZero();
32 moveX.add(-2+4*dir, 0);
33 }
35 public Rectangle getRect() {
36 return new Rectangle(position.x, position.y, width, height);
37 }
38 }