Move ship & bullet to the objects module
This commit is contained in:
@@ -13,9 +13,8 @@ use crate::config::{
|
|||||||
PLAYER_SHIP_COLOR, SHIP_ROTATION, SHIP_THRUST, SHIP_THRUSTER_COLOR_ACTIVE,
|
PLAYER_SHIP_COLOR, SHIP_ROTATION, SHIP_THRUST, SHIP_THRUSTER_COLOR_ACTIVE,
|
||||||
SHIP_THRUSTER_COLOR_INACTIVE, WINDOW_SIZE,
|
SHIP_THRUSTER_COLOR_INACTIVE, WINDOW_SIZE,
|
||||||
};
|
};
|
||||||
use crate::objects::Asteroid;
|
use crate::objects::{Asteroid, Bullet, Ship};
|
||||||
use crate::physics::AngularVelocity;
|
use crate::physics::AngularVelocity;
|
||||||
use crate::ship::{Bullet, Ship};
|
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_inspector_egui::InspectorOptions;
|
use bevy_inspector_egui::InspectorOptions;
|
||||||
@@ -336,7 +335,7 @@ fn input_ship_shoot(
|
|||||||
// For now, spawn one for each press of the spacebar.
|
// For now, spawn one for each press of the spacebar.
|
||||||
if keyboard_input.just_pressed(KeyCode::Space) {
|
if keyboard_input.just_pressed(KeyCode::Space) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
ship::Bullet,
|
Bullet,
|
||||||
Collider::ball(0.2),
|
Collider::ball(0.2),
|
||||||
Sensor,
|
Sensor,
|
||||||
ActiveEvents::COLLISION_EVENTS,
|
ActiveEvents::COLLISION_EVENTS,
|
||||||
|
|||||||
@@ -23,3 +23,9 @@ impl AsteroidSize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct Ship;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct Bullet;
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
AngularVelocity, GameAssets, GameState, Lives,
|
AngularVelocity, GameAssets, GameState, Lives,
|
||||||
objects::Asteroid,
|
|
||||||
events::{BulletDestroy, ShipDestroy},
|
events::{BulletDestroy, ShipDestroy},
|
||||||
|
objects::{Asteroid, Ship},
|
||||||
physics::{Velocity, Wrapping},
|
physics::{Velocity, Wrapping},
|
||||||
};
|
};
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_rapier2d::prelude::*;
|
use bevy_rapier2d::prelude::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct Ship;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct Bullet;
|
|
||||||
|
|
||||||
pub fn spawn_player(mut commands: Commands, game_assets: Res<GameAssets>) {
|
pub fn spawn_player(mut commands: Commands, game_assets: Res<GameAssets>) {
|
||||||
commands
|
commands
|
||||||
.spawn((
|
.spawn((
|
||||||
|
|||||||
Reference in New Issue
Block a user