1 package ru
.deadsoftware
.cavecraft
.game
.objects
;
3 import com
.badlogic
.gdx
.math
.Rectangle
;
4 import com
.badlogic
.gdx
.math
.Vector2
;
5 import ru
.deadsoftware
.cavecraft
.game
.GameItems
;
6 import ru
.deadsoftware
.cavecraft
.game
.GameWorld
;
8 import java
.io
.Serializable
;
10 public class Player
implements Serializable
{
12 public static int ANIM_SPEED
= 6;
16 public int width
, height
, dir
, texWidth
, hp
;
17 public boolean canJump
;
19 public boolean flyMode
= false;
22 public Player(GameWorld world
, int gameMode
) {
23 this.gameMode
= gameMode
;
24 pos
= getSpawnPoint(world
).cpy();
25 move
= new Vector2(0, 0);
33 public void respawn(GameWorld world
) {
34 pos
.set(getSpawnPoint(world
));
39 private Vector2
getSpawnPoint(GameWorld world
) {
41 for (y
= 0; y
< world
.getHeight(); y
++) {
42 if (y
== world
.getHeight() - 1) {
44 world
.setForeMap(x
, y
, 1);
47 if (world
.getForeMap(x
, y
) > 0 && GameItems
.getBlock(world
.getForeMap(x
, y
)).coll
) break;
49 x
= x
* 16 + texWidth
/ 2;
51 return new Vector2(x
, y
);
54 public Rectangle
getRect() {
55 return new Rectangle(pos
.x
+ 2, pos
.y
, width
, height
);