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