diff options
author | Henauxg <19689618+Henauxg@users.noreply.github.com> | 2022-11-03 13:55:19 +0100 |
---|---|---|
committer | Henauxg <19689618+Henauxg@users.noreply.github.com> | 2022-11-03 13:55:19 +0100 |
commit | 6708e7c4bd6d7c43788549c30e52624e0b77346d (patch) | |
tree | eac3535f0acfe3e335b2cff39f1a0bdebc35c7e7 /examples/breakout/protocol.rs | |
parent | 78929ec19b606449092ce042a2947fcfb000ff33 (diff) |
[example:breakout] Continue server & client implementation, spawns, paddle movements
Diffstat (limited to 'examples/breakout/protocol.rs')
-rw-r--r-- | examples/breakout/protocol.rs | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/examples/breakout/protocol.rs b/examples/breakout/protocol.rs index 9cb9232..766094a 100644 --- a/examples/breakout/protocol.rs +++ b/examples/breakout/protocol.rs @@ -1,25 +1,47 @@ +use bevy::prelude::{Entity, Vec2, Vec3}; use bevy_quinnet::ClientId; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum Input {} +#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub(crate) enum PaddleInput { + #[default] + None, + Left, + Right, +} // Messages from clients #[derive(Debug, Clone, Serialize, Deserialize)] -pub enum ClientMessage { - // Join {}, - // Disconnect {}, - PaddleInput {}, +pub(crate) enum ClientMessage { + PaddleInput { input: PaddleInput }, } // Messages from the server #[derive(Debug, Clone, Serialize, Deserialize)] -pub enum ServerMessage { - // ClientConnected { client_id: ClientId }, - // ClientDisconnected { client_id: ClientId }, - InitClient { client_id: ClientId }, - GameStart {}, - BrickDestroyed {}, - BallPosition {}, - PaddlePosition {}, +pub(crate) enum ServerMessage { + InitClient { + client_id: ClientId, + }, + SpawnPaddle { + client_id: ClientId, + entity: Entity, + position: Vec3, + }, + SpawnBall { + entity: Entity, + position: Vec3, + direction: Vec2, + }, + StartGame {}, + BrickDestroyed { + client_id: ClientId, + }, + BallPosition { + entity: Entity, + position: Vec3, + }, + PaddlePosition { + entity: Entity, + position: Vec3, + }, } |