Marker components for the ball & paddles
This commit is contained in:
@@ -76,6 +76,7 @@ fn setup_game(
|
||||
) {
|
||||
// ball
|
||||
commands.spawn((
|
||||
Ball,
|
||||
Mesh2d(meshes.add(Circle::new(10.0))),
|
||||
MeshMaterial2d(materials.add(Color::srgb(1.0, 0.0, 0.0))),
|
||||
Transform::default(),
|
||||
@@ -85,23 +86,32 @@ fn setup_game(
|
||||
let paddle_material = materials.add(Color::WHITE);
|
||||
// Player 1
|
||||
commands.spawn((
|
||||
// TODO: Marker component for player
|
||||
// Maybe one for each player?
|
||||
// Maybe it can hold the WebSocket, too.
|
||||
// *Maybe* I can have one struct with an Option<Ws> to know which
|
||||
// player is the local one (the one with a socket).
|
||||
Paddle,
|
||||
Mesh2d(paddle_mesh.clone()),
|
||||
MeshMaterial2d(paddle_material.clone()),
|
||||
Transform::from_xyz(-window.width() / 2.0 + PADDLE_GAP, 0.0, 1.0),
|
||||
));
|
||||
// Player 2
|
||||
commands.spawn((
|
||||
Paddle,
|
||||
Mesh2d(paddle_mesh),
|
||||
MeshMaterial2d(paddle_material),
|
||||
Transform::from_xyz(window.width() / 2.0 - PADDLE_GAP, 0.0, 1.0),
|
||||
));
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
struct Ball;
|
||||
|
||||
/// Marker component for player paddles
|
||||
///
|
||||
/// Maybe one for each player?
|
||||
/// Maybe it can hold the WebSocket, too.
|
||||
/// *Maybe* I can have one struct with an Option<Ws> to know which
|
||||
/// player is the local one (the one with a socket).
|
||||
#[derive(Component)]
|
||||
struct Paddle;
|
||||
|
||||
/// ECS Component to hold the WebSocket. I guess there's going to be a magic
|
||||
/// entity that controls the networking.
|
||||
#[derive(Component)]
|
||||
|
||||
Reference in New Issue
Block a user