1 package ru
.deadsoftware
.cavecraft
.game
.mobs
;
3 import com
.badlogic
.gdx
.graphics
.g2d
.Sprite
;
4 import com
.badlogic
.gdx
.graphics
.g2d
.SpriteBatch
;
5 import com
.badlogic
.gdx
.math
.RandomXS128
;
6 import com
.badlogic
.gdx
.math
.Rectangle
;
7 import com
.badlogic
.gdx
.math
.Vector2
;
8 import ru
.deadsoftware
.cavecraft
.Assets
;
9 import ru
.deadsoftware
.cavecraft
.game
.GameProc
;
11 public class Human
extends Mob
{
13 private RandomXS128 rand
= new RandomXS128();
14 private GameProc gameProc
;
15 private Sprite
[][] tex
;
17 public Human(int x
, int y
, GameProc gameProc
) {
18 this.gameProc
= gameProc
;
19 position
= new Vector2(x
, y
);
20 moveX
= new Vector2(0, 0);
21 moveY
= new Vector2(0, 0);
26 tex
= Assets
.playerSkin
.clone();
33 if (canJump
&& gameProc
.world
.getForeMap(
34 (int)(position
.x
/16)+(dir
*2-1), (int)(position
.y
/16)+1)>0)
36 if (rand
.nextInt(500)>490) dir
++;
39 moveX
.add(-2+4*dir
, 0);
43 public void draw(SpriteBatch spriteBatch
, float x
, float y
) {
45 animation
+=Mob
.ANIM_SPEED
*anim_d
;
46 if (animation
<=-60 || animation
>=60) anim_d
=-anim_d
;
48 tex
[0][2].setRotation(animation
);
49 tex
[1][2].setRotation(-animation
);
50 tex
[0][3].setRotation(-animation
);
51 tex
[1][3].setRotation(animation
);
52 spriteBatch
.draw(tex
[dir
][0], x
-2, y
-2);
53 if (tex
[0][2].getRotation()>=60 || tex
[0][2].getRotation()<=-60)
54 Mob
.ANIM_SPEED
= -Mob
.ANIM_SPEED
;
55 tex
[1][2].setPosition(x
-6,y
);
56 tex
[1][2].draw(spriteBatch
);
57 tex
[1][3].setPosition(x
-6, y
+10);
58 tex
[1][3].draw(spriteBatch
);
59 tex
[0][3].setPosition(x
-6, y
+10);
60 tex
[0][3].draw(spriteBatch
);
61 spriteBatch
.draw(tex
[dir
][1], x
-2, y
+ 8);
63 tex
[0][2].setPosition(x
-6, y
);
64 tex
[0][2].draw(spriteBatch
);
67 public Rectangle
getRect() {
68 return new Rectangle(position
.x
, position
.y
, width
, height
);