diff options
Diffstat (limited to 'shared/src/main/java/kz/ilotterytea/frogartha/domain')
| -rw-r--r-- | shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java | 42 | ||||
| -rw-r--r-- | shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java | 32 |
2 files changed, 74 insertions, 0 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 new file mode 100644 index 0000000..15ba015 --- /dev/null +++ b/shared/src/main/java/kz/ilotterytea/frogartha/domain/PlayerState.java @@ -0,0 +1,42 @@ +package kz.ilotterytea.frogartha.domain; + +import com.badlogic.gdx.math.Vector3; + +public class PlayerState { + private final Vector3 position, direction; + private float nextJumpTimestamp; + + public PlayerState() { + this(new Vector3(), new Vector3()); + } + + public PlayerState(Vector3 position, Vector3 direction) { + this.position = position; + this.direction = direction; + this.nextJumpTimestamp = 0; + } + + public Vector3 getPosition() { + return position; + } + + public void setPosition(float x, float y, float z) { + this.position.set(x, y, z); + } + + public Vector3 getDirection() { + return direction; + } + + public float getNextJumpTimestamp() { + return nextJumpTimestamp; + } + + public void setNextJumpTimestamp(float nextJumpTimestamp) { + this.nextJumpTimestamp = nextJumpTimestamp; + } + + public void setDirection(float x, float y, float z) { + this.position.set(x, y, z); + } +} diff --git a/shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java b/shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java new file mode 100644 index 0000000..272f514 --- /dev/null +++ b/shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java @@ -0,0 +1,32 @@ +package kz.ilotterytea.frogartha.domain.client; + +import com.github.czyzby.websocket.serialization.SerializationException; +import com.github.czyzby.websocket.serialization.Transferable; +import com.github.czyzby.websocket.serialization.impl.Deserializer; +import com.github.czyzby.websocket.serialization.impl.Serializer; +import kz.ilotterytea.frogartha.FrogarthaConstants; + +public class PlayerJumpAction implements Transferable<PlayerJumpAction> { + private float jumpStrength; + + public PlayerJumpAction() { + } + + public PlayerJumpAction(Float jumpStrength) { + this.jumpStrength = Math.min(jumpStrength, FrogarthaConstants.Player.MAX_JUMP_STRENGTH); + } + + public float getJumpStrength() { + return jumpStrength; + } + + @Override + public void serialize(Serializer serializer) throws SerializationException { + serializer.serializeFloat(jumpStrength); + } + + @Override + public PlayerJumpAction deserialize(Deserializer deserializer) throws SerializationException { + return new PlayerJumpAction(deserializer.deserializeFloat()); + } +} |
