1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
use bevy::prelude::{Entity, Vec2, Vec3};
use bevy_quinnet::shared::ClientId;
use serde::{Deserialize, Serialize};
use crate::BrickId;
#[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(crate) enum ClientMessage {
PaddleInput { input: PaddleInput },
}
// Messages from the server
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) enum ServerMessage {
InitClient {
client_id: ClientId,
},
SpawnPaddle {
owner_client_id: ClientId,
entity: Entity,
position: Vec3,
},
SpawnBall {
owner_client_id: ClientId,
entity: Entity,
position: Vec3,
direction: Vec2,
},
SpawnBricks {
offset: Vec2,
rows: usize,
columns: usize,
},
StartGame,
BrickDestroyed {
by_client_id: ClientId,
brick_id: BrickId,
},
BallCollided {
owner_client_id: ClientId,
entity: Entity,
position: Vec3,
velocity: Vec2,
},
PaddleMoved {
entity: Entity,
position: Vec3,
},
}
|