summaryrefslogtreecommitdiff
path: root/shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java')
-rw-r--r--shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java b/shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java
index d745822..0aa89c5 100644
--- a/shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java
+++ b/shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java
@@ -1,5 +1,6 @@
package kz.ilotterytea.frogartha.domain;
+import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.github.czyzby.websocket.serialization.SerializationException;
import com.github.czyzby.websocket.serialization.Transferable;
@@ -7,14 +8,15 @@ import com.github.czyzby.websocket.serialization.impl.Deserializer;
import com.github.czyzby.websocket.serialization.impl.Serializer;
public class PlayerState implements Transferable<PlayerState> {
- private final Vector3 position, direction;
+ private final Vector3 position;
+ private final Vector2 direction;
private float nextJumpTimestamp;
public PlayerState() {
- this(new Vector3(), new Vector3());
+ this(new Vector3(), new Vector2());
}
- public PlayerState(Vector3 position, Vector3 direction) {
+ public PlayerState(Vector3 position, Vector2 direction) {
this.position = position;
this.direction = direction;
this.nextJumpTimestamp = 0;
@@ -28,7 +30,7 @@ public class PlayerState implements Transferable<PlayerState> {
this.position.set(x, y, z);
}
- public Vector3 getDirection() {
+ public Vector2 getDirection() {
return direction;
}
@@ -40,22 +42,23 @@ public class PlayerState implements Transferable<PlayerState> {
this.nextJumpTimestamp = nextJumpTimestamp;
}
- public void setDirection(float x, float y, float z) {
- this.direction.set(x, y, z);
+ public void setDirection(float x, float z) {
+ this.direction.set(x, z);
}
@Override
public void serialize(Serializer serializer) throws SerializationException {
serializer
.serializeFloatArray(new float[]{position.x, position.y, position.z})
- .serializeFloatArray(new float[]{direction.x, direction.y, direction.z});
+ .serializeFloat(direction.x)
+ .serializeFloat(direction.y);
}
@Override
public PlayerState deserialize(Deserializer deserializer) throws SerializationException {
return new PlayerState(
new Vector3(deserializer.deserializeFloatArray()),
- new Vector3(deserializer.deserializeFloatArray())
+ new Vector2(deserializer.deserializeFloat(), deserializer.deserializeFloat())
);
}
}