28 lines
838 B
Rust
28 lines
838 B
Rust
use avian2d::prelude::*;
|
|
use bevy::prelude::*;
|
|
|
|
use crate::AppState;
|
|
|
|
/// Basic implementation of a physics object
|
|
#[derive(Component, Default)]
|
|
#[require(Collider, Mesh2d, MeshMaterial2d<ColorMaterial>, Restitution = Restitution::new(1.0), RigidBody, TransformInterpolation, Transform, StateScoped<AppState> = StateScoped(AppState::InGame))]
|
|
struct GameObject;
|
|
|
|
/// Radius of a ball
|
|
#[derive(Component, Default)]
|
|
pub struct Radius(pub f32);
|
|
|
|
/// A basic ball with which to interact
|
|
#[derive(Component, Default)]
|
|
#[require(GameObject, RigidBody = RigidBody::Dynamic, Radius)]
|
|
pub struct Ball;
|
|
|
|
/// The controllable ball
|
|
#[derive(Component, Default)]
|
|
#[require(Ball)]
|
|
pub struct Player;
|
|
|
|
/// The static objects bounding the playable area
|
|
#[derive(Component, Default)]
|
|
#[require(GameObject, RigidBody = RigidBody::Static)]
|
|
pub struct Wall;
|