diff options
| author | ilotterytea <iltsu@alright.party> | 2025-01-22 00:40:57 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-01-22 00:41:39 +0500 |
| commit | a7f77c115bc95eb8a667df1146cc26dc17367879 (patch) | |
| tree | 77b08b0cb4f07f9b3d21c277d5621bd0ee5a488c /shared/src/main/java/kz/ilotterytea/frogartha/events/PlayerJumpEvent.java | |
| parent | e4997681a2d08adc9b9055b0b2a1dc52d54edd47 (diff) | |
feat: player jumps like a frog!!! (FROGartha reference) + player state
Diffstat (limited to 'shared/src/main/java/kz/ilotterytea/frogartha/events/PlayerJumpEvent.java')
| -rw-r--r-- | shared/src/main/java/kz/ilotterytea/frogartha/events/PlayerJumpEvent.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/shared/src/main/java/kz/ilotterytea/frogartha/events/PlayerJumpEvent.java b/shared/src/main/java/kz/ilotterytea/frogartha/events/PlayerJumpEvent.java new file mode 100644 index 0000000..a084555 --- /dev/null +++ b/shared/src/main/java/kz/ilotterytea/frogartha/events/PlayerJumpEvent.java @@ -0,0 +1,58 @@ +package kz.ilotterytea.frogartha.events; + +import com.badlogic.gdx.math.Vector3; +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; + +public class PlayerJumpEvent extends Event implements Transferable<PlayerJumpEvent> { + private Vector3 startPosition, endPosition; + private float jumpStrength; + + public PlayerJumpEvent() { + super(); + } + + public PlayerJumpEvent(Integer playerId, Vector3 startPosition, Vector3 endPosition, Float jumpStrength) { + super(playerId); + this.startPosition = startPosition; + this.endPosition = endPosition; + this.jumpStrength = jumpStrength; + } + + public Vector3 getStartPosition() { + return startPosition; + } + + public Vector3 getEndPosition() { + return endPosition; + } + + public float getJumpStrength() { + return jumpStrength; + } + + @Override + public void serialize(Serializer serializer) throws SerializationException { + serializer + // id + .serializeInt(playerId) + // start position + .serializeFloatArray(new float[]{startPosition.x, startPosition.y, startPosition.z}) + // end position + .serializeFloatArray(new float[]{endPosition.x, endPosition.y, endPosition.z}) + // jump strength + .serializeFloat(jumpStrength); + } + + @Override + public PlayerJumpEvent deserialize(Deserializer deserializer) throws SerializationException { + return new PlayerJumpEvent( + deserializer.deserializeInt(), + new Vector3(deserializer.deserializeFloatArray()), + new Vector3(deserializer.deserializeFloatArray()), + deserializer.deserializeFloat() + ); + } +} |
