Compare commits
2 Commits
f553574e3e
...
ab5f489450
| Author | SHA1 | Date | |
|---|---|---|---|
| ab5f489450 | |||
| d4ceaa6312 |
@@ -1,4 +1,4 @@
|
|||||||
use bevy_rapier2d::prelude::Collider;
|
use bevy_rapier2d::prelude::*;
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@@ -118,6 +118,7 @@ pub fn spawn_asteroid(
|
|||||||
commands.spawn((
|
commands.spawn((
|
||||||
Asteroid(AsteroidSize::Small),
|
Asteroid(AsteroidSize::Small),
|
||||||
Collider::ball(collider_radius),
|
Collider::ball(collider_radius),
|
||||||
|
Sensor,
|
||||||
Position(spawn.pos),
|
Position(spawn.pos),
|
||||||
Velocity(spawn.vel),
|
Velocity(spawn.vel),
|
||||||
Rotation(0.0),
|
Rotation(0.0),
|
||||||
|
|||||||
17
src/lib.rs
17
src/lib.rs
@@ -10,7 +10,11 @@ use bevy::prelude::*;
|
|||||||
use bevy_inspector_egui::InspectorOptions;
|
use bevy_inspector_egui::InspectorOptions;
|
||||||
use bevy_inspector_egui::prelude::ReflectInspectorOptions;
|
use bevy_inspector_egui::prelude::ReflectInspectorOptions;
|
||||||
|
|
||||||
use bevy_rapier2d::{plugin::{NoUserData, RapierPhysicsPlugin}, prelude::Collider, render::RapierDebugRenderPlugin};
|
use bevy_rapier2d::{
|
||||||
|
plugin::{NoUserData, RapierPhysicsPlugin},
|
||||||
|
prelude::*,
|
||||||
|
render::RapierDebugRenderPlugin,
|
||||||
|
};
|
||||||
use config::{ASTEROID_SMALL_COLOR, SHIP_THRUSTER_COLOR_ACTIVE, SHIP_THRUSTER_COLOR_INACTIVE};
|
use config::{ASTEROID_SMALL_COLOR, SHIP_THRUSTER_COLOR_ACTIVE, SHIP_THRUSTER_COLOR_INACTIVE};
|
||||||
|
|
||||||
pub struct AsteroidPlugin;
|
pub struct AsteroidPlugin;
|
||||||
@@ -43,6 +47,8 @@ impl Plugin for AsteroidPlugin {
|
|||||||
wrap_entities,
|
wrap_entities,
|
||||||
asteroids::tick_asteroid_manager,
|
asteroids::tick_asteroid_manager,
|
||||||
asteroids::spawn_asteroid.after(asteroids::tick_asteroid_manager),
|
asteroids::spawn_asteroid.after(asteroids::tick_asteroid_manager),
|
||||||
|
// TODO: Remove debug printing
|
||||||
|
debug_collision_event_printer,
|
||||||
)
|
)
|
||||||
.run_if(in_state(GameState::Playing)),
|
.run_if(in_state(GameState::Playing)),
|
||||||
)
|
)
|
||||||
@@ -56,6 +62,12 @@ impl Plugin for AsteroidPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn debug_collision_event_printer(mut collision_events: EventReader<CollisionEvent>) {
|
||||||
|
for event in collision_events.read() {
|
||||||
|
dbg!(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, States)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, States)]
|
||||||
pub enum GameState {
|
pub enum GameState {
|
||||||
TitleScreen, // Program is started. Present title screen and await user start
|
TitleScreen, // Program is started. Present title screen and await user start
|
||||||
@@ -180,6 +192,9 @@ fn spawn_player(mut commands: Commands, game_assets: Res<GameAssets>) {
|
|||||||
commands
|
commands
|
||||||
.spawn((
|
.spawn((
|
||||||
Collider::ball(0.7),
|
Collider::ball(0.7),
|
||||||
|
Sensor,
|
||||||
|
ActiveEvents::COLLISION_EVENTS,
|
||||||
|
ActiveCollisionTypes::STATIC_STATIC,
|
||||||
Ship,
|
Ship,
|
||||||
Wrapping,
|
Wrapping,
|
||||||
Position(Vec2::default()),
|
Position(Vec2::default()),
|
||||||
|
|||||||
Reference in New Issue
Block a user