|
|
|
@ -99,8 +99,8 @@ fn main() {
|
|
|
|
(update_tooltip, debug_trail).run_if(in_state(DebuggingState::On)),
|
|
|
|
(update_tooltip, debug_trail).run_if(in_state(DebuggingState::On)),
|
|
|
|
// TODO: Add run_if to this system
|
|
|
|
// TODO: Add run_if to this system
|
|
|
|
update_batch_position.run_if(any_component_changed::<Batch>),
|
|
|
|
update_batch_position.run_if(any_component_changed::<Batch>),
|
|
|
|
move_batches.run_if(on_event::<CollisionStarted>.or(on_event::<CollisionEnded>)),
|
|
|
|
move_batches.run_if(on_message::<CollisionStarted>.or(on_message::<CollisionEnded>)),
|
|
|
|
manage_score.run_if(on_event::<CollisionStarted>.or(on_event::<CollisionEnded>)),
|
|
|
|
manage_score.run_if(on_message::<CollisionStarted>.or(on_message::<CollisionEnded>)),
|
|
|
|
shimmer_button::<RewindButton>.run_if(in_state(PlayerState::Stasis)),
|
|
|
|
shimmer_button::<RewindButton>.run_if(in_state(PlayerState::Stasis)),
|
|
|
|
shimmer_button::<FlapButton>.run_if(in_state(PlayerState::Pause)),
|
|
|
|
shimmer_button::<FlapButton>.run_if(in_state(PlayerState::Pause)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -265,20 +265,20 @@ fn init_first_batches(mut commands: Commands) {
|
|
|
|
/// * The pipe obstacle
|
|
|
|
/// * The pipe obstacle
|
|
|
|
/// * The pipe scoring sensor
|
|
|
|
/// * The pipe scoring sensor
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// These are all populated via `OnAdd` observers for the respected components.
|
|
|
|
/// These are all populated via `On<Add, >` observers for the respected components.
|
|
|
|
/// This makes it much more concise to spawn each part of the environment.
|
|
|
|
/// This makes it much more concise to spawn each part of the environment.
|
|
|
|
fn populate_batch(
|
|
|
|
fn populate_batch(
|
|
|
|
trigger: Trigger<OnAdd, Batch>,
|
|
|
|
event: On<Add, Batch>,
|
|
|
|
batches: Query<&Batch>,
|
|
|
|
batches: Query<&Batch>,
|
|
|
|
children: Query<&ChildOf>,
|
|
|
|
children: Query<&ChildOf>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
// Only run this for top level batch entities,
|
|
|
|
// Only run this for top level batch entities,
|
|
|
|
// not children containing a reference to their batch, like hitboxes
|
|
|
|
// not children containing a reference to their batch, like hitboxes
|
|
|
|
if !children.contains(trigger.target()) {
|
|
|
|
if !children.contains(event.entity) {
|
|
|
|
let Batch(batch_id) = batches.get(trigger.target()).unwrap();
|
|
|
|
let Batch(batch_id) = batches.get(event.entity).unwrap();
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.entity(trigger.target())
|
|
|
|
.entity(event.entity)
|
|
|
|
.insert((
|
|
|
|
.insert((
|
|
|
|
Transform::from_xyz(500.0 * (*batch_id) as f32, 0.0, 0.0),
|
|
|
|
Transform::from_xyz(500.0 * (*batch_id) as f32, 0.0, 0.0),
|
|
|
|
Visibility::Inherited,
|
|
|
|
Visibility::Inherited,
|
|
|
|
@ -313,14 +313,14 @@ fn update_batch_position(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn populate_ground(
|
|
|
|
fn populate_ground(
|
|
|
|
trigger: Trigger<OnAdd, Ground>,
|
|
|
|
event: On<Add, Ground>,
|
|
|
|
grounds: Query<&Ground>,
|
|
|
|
grounds: Query<&Ground>,
|
|
|
|
ground_assets: Res<GroundAssets>,
|
|
|
|
ground_assets: Res<GroundAssets>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let Ground(idx) = grounds.get(trigger.target()).unwrap();
|
|
|
|
let Ground(idx) = grounds.get(event.entity).unwrap();
|
|
|
|
debug!("populating ground {:?}", idx);
|
|
|
|
debug!("populating ground {:?}", idx);
|
|
|
|
commands.entity(trigger.target()).insert((
|
|
|
|
commands.entity(event.entity).insert((
|
|
|
|
ground_assets.material.clone(),
|
|
|
|
ground_assets.material.clone(),
|
|
|
|
ground_assets.mesh.clone(),
|
|
|
|
ground_assets.mesh.clone(),
|
|
|
|
Name::new("ground"),
|
|
|
|
Name::new("ground"),
|
|
|
|
@ -331,14 +331,14 @@ fn populate_ground(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn populate_ceiling(
|
|
|
|
fn populate_ceiling(
|
|
|
|
trigger: Trigger<OnAdd, Ceiling>,
|
|
|
|
event: On<Add, Ceiling>,
|
|
|
|
ceiling: Query<&Ceiling>,
|
|
|
|
ceiling: Query<&Ceiling>,
|
|
|
|
ceiling_assets: Res<CeilingAssets>,
|
|
|
|
ceiling_assets: Res<CeilingAssets>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let Ceiling(idx) = ceiling.get(trigger.target()).unwrap();
|
|
|
|
let Ceiling(idx) = ceiling.get(event.entity).unwrap();
|
|
|
|
debug!("populating ceiling{:?}", idx);
|
|
|
|
debug!("populating ceiling{:?}", idx);
|
|
|
|
commands.entity(trigger.target()).insert((
|
|
|
|
commands.entity(event.entity).insert((
|
|
|
|
ceiling_assets.material.clone(),
|
|
|
|
ceiling_assets.material.clone(),
|
|
|
|
ceiling_assets.mesh.clone(),
|
|
|
|
ceiling_assets.mesh.clone(),
|
|
|
|
Name::new("ceiling"),
|
|
|
|
Name::new("ceiling"),
|
|
|
|
@ -349,11 +349,11 @@ fn populate_ceiling(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn move_pipe(
|
|
|
|
fn move_pipe(
|
|
|
|
trigger: Trigger<OnInsert, Batch>,
|
|
|
|
event: On<OnInsert, Batch>,
|
|
|
|
mut pipes: Query<(&Batch, &Pipe, &mut Transform)>,
|
|
|
|
mut pipes: Query<(&Batch, &Pipe, &mut Transform)>,
|
|
|
|
rand: Res<Rand>,
|
|
|
|
rand: Res<Rand>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if let Ok((Batch(id), pipe, mut pipe_t)) = pipes.get_mut(trigger.target()) {
|
|
|
|
if let Ok((Batch(id), pipe, mut pipe_t)) = pipes.get_mut(event.entity) {
|
|
|
|
*pipe_t =
|
|
|
|
*pipe_t =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let offset = {
|
|
|
|
let offset = {
|
|
|
|
@ -382,14 +382,14 @@ fn move_pipe(
|
|
|
|
/// Based on if this is a Top or Bottom pipe the placement changes
|
|
|
|
/// Based on if this is a Top or Bottom pipe the placement changes
|
|
|
|
/// Otherwise this just spawns in the center of the batch.
|
|
|
|
/// Otherwise this just spawns in the center of the batch.
|
|
|
|
fn populate_pipe(
|
|
|
|
fn populate_pipe(
|
|
|
|
trigger: Trigger<OnAdd, Pipe>,
|
|
|
|
event: On<Add, Pipe>,
|
|
|
|
pipes: Query<(&Batch, &Pipe)>,
|
|
|
|
pipes: Query<(&Batch, &Pipe)>,
|
|
|
|
pipe_assets: Res<PipeAssets>,
|
|
|
|
pipe_assets: Res<PipeAssets>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
rand: Res<Rand>,
|
|
|
|
rand: Res<Rand>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let pipe_t = {
|
|
|
|
let pipe_t = {
|
|
|
|
let (Batch(id), pipe) = pipes.get(trigger.target()).unwrap();
|
|
|
|
let (Batch(id), pipe) = pipes.get(event.entity).unwrap();
|
|
|
|
let offset = {
|
|
|
|
let offset = {
|
|
|
|
let val = rand.0.hash_one(id);
|
|
|
|
let val = rand.0.hash_one(id);
|
|
|
|
|
|
|
|
|
|
|
|
@ -413,7 +413,7 @@ fn populate_pipe(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
commands.entity(trigger.target()).insert((
|
|
|
|
commands.entity(event.entity).insert((
|
|
|
|
pipe_t,
|
|
|
|
pipe_t,
|
|
|
|
pipe_assets.material.clone(),
|
|
|
|
pipe_assets.material.clone(),
|
|
|
|
pipe_assets.mesh.clone(),
|
|
|
|
pipe_assets.mesh.clone(),
|
|
|
|
@ -425,8 +425,8 @@ fn populate_pipe(
|
|
|
|
|
|
|
|
|
|
|
|
/// The hitbox should cover the entire height of the screen so if the player
|
|
|
|
/// The hitbox should cover the entire height of the screen so if the player
|
|
|
|
/// passes between the pipes it registers a point
|
|
|
|
/// passes between the pipes it registers a point
|
|
|
|
fn populate_hitbox(trigger: Trigger<OnAdd, Hitbox>, mut commands: Commands) {
|
|
|
|
fn populate_hitbox(event: On<Add, Hitbox>, mut commands: Commands) {
|
|
|
|
commands.entity(trigger.target()).insert((
|
|
|
|
commands.entity(event.entity).insert((
|
|
|
|
RigidBody::Static,
|
|
|
|
RigidBody::Static,
|
|
|
|
Collider::rectangle(1.0, 10.0),
|
|
|
|
Collider::rectangle(1.0, 10.0),
|
|
|
|
Sensor,
|
|
|
|
Sensor,
|
|
|
|
@ -517,7 +517,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BackgroundColor(Color::WHITE),
|
|
|
|
BackgroundColor(Color::WHITE),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
PlayerState::Stasis,
|
|
|
|
PlayerState::Stasis,
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
@ -569,7 +569,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
},))
|
|
|
|
},))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
fn show_credits(
|
|
|
|
fn show_credits(
|
|
|
|
_trigger: Trigger<Pointer<Click>>,
|
|
|
|
_event: On<Pointer<Click>>,
|
|
|
|
mut state: ResMut<NextState<PlayerState>>,
|
|
|
|
mut state: ResMut<NextState<PlayerState>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
state.set(PlayerState::Credits);
|
|
|
|
state.set(PlayerState::Credits);
|
|
|
|
@ -579,7 +579,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
Node { ..default() },
|
|
|
|
Node { ..default() },
|
|
|
|
children![(TextColor(BLACK.into()), Text::new("Credits")),],
|
|
|
|
children![(TextColor(BLACK.into()), Text::new("Credits")),],
|
|
|
|
))
|
|
|
|
))
|
|
|
|
@ -588,7 +588,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fn quit_game(
|
|
|
|
fn quit_game(
|
|
|
|
_trigger: Trigger<Pointer<Click>>,
|
|
|
|
_event: On<Pointer<Click>>,
|
|
|
|
mut exit: EventWriter<AppExit>,
|
|
|
|
mut exit: EventWriter<AppExit>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
warn!("Quitting game");
|
|
|
|
warn!("Quitting game");
|
|
|
|
@ -598,7 +598,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
parent
|
|
|
|
parent
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
Node { ..default() },
|
|
|
|
Node { ..default() },
|
|
|
|
children![(Text::new("Quit"), TextColor(BLACK.into()))],
|
|
|
|
children![(Text::new("Quit"), TextColor(BLACK.into()))],
|
|
|
|
@ -608,7 +608,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fn hide_credits(_trigger: Trigger<Pointer<Click>>, mut state: ResMut<NextState<PlayerState>>) {
|
|
|
|
fn hide_credits(_event: On<Pointer<Click>>, mut state: ResMut<NextState<PlayerState>>) {
|
|
|
|
state.set(PlayerState::Stasis)
|
|
|
|
state.set(PlayerState::Stasis)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -624,7 +624,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BackgroundColor(WHITE.into()),
|
|
|
|
BackgroundColor(WHITE.into()),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
PlayerState::Credits,
|
|
|
|
PlayerState::Credits,
|
|
|
|
children![(
|
|
|
|
children![(
|
|
|
|
Text::new(credits_str),
|
|
|
|
Text::new(credits_str),
|
|
|
|
@ -639,7 +639,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
children![(Text::new("Close"), TextColor(BLACK.into()))],
|
|
|
|
children![(Text::new("Close"), TextColor(BLACK.into()))],
|
|
|
|
));
|
|
|
|
));
|
|
|
|
@ -679,7 +679,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
Text::new("(paused)"),
|
|
|
|
Text::new("(paused)"),
|
|
|
|
TextColor(BLACK.into()),
|
|
|
|
TextColor(BLACK.into()),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@ -714,7 +714,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
BackgroundColor(Color::WHITE.with_alpha(0.9)),
|
|
|
|
BackgroundColor(Color::WHITE.with_alpha(0.9)),
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
RewindButton,
|
|
|
|
RewindButton,
|
|
|
|
@ -757,7 +757,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
BackgroundColor(Color::WHITE.with_alpha(0.9)),
|
|
|
|
BackgroundColor(Color::WHITE.with_alpha(0.9)),
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
FlapButton,
|
|
|
|
FlapButton,
|
|
|
|
@ -792,7 +792,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BorderRadius::all(Val::Px(5.0)),
|
|
|
|
BackgroundColor(Color::WHITE),
|
|
|
|
BackgroundColor(Color::WHITE),
|
|
|
|
BorderColor(BLACK.into()),
|
|
|
|
BorderColor::all(BLACK),
|
|
|
|
children![(
|
|
|
|
children![(
|
|
|
|
SyncResource::<Score>::default(),
|
|
|
|
SyncResource::<Score>::default(),
|
|
|
|
Text::default(),
|
|
|
|
Text::default(),
|
|
|
|
@ -845,16 +845,16 @@ fn init_background(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn start_rewind(_trigger: Trigger<Pointer<Pressed>>, mut next: ResMut<NextState<PlayerState>>) {
|
|
|
|
fn start_rewind(_event: On<Pointer<Pressed>>, mut next: ResMut<NextState<PlayerState>>) {
|
|
|
|
next.set(PlayerState::Rewind);
|
|
|
|
next.set(PlayerState::Rewind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn end_rewind(_trigger: Trigger<Pointer<Released>>, mut next: ResMut<NextState<PlayerState>>) {
|
|
|
|
fn end_rewind(_event: On<Pointer<Released>>, mut next: ResMut<NextState<PlayerState>>) {
|
|
|
|
next.set(PlayerState::Alive);
|
|
|
|
next.set(PlayerState::Alive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn flap_button(
|
|
|
|
fn flap_button(
|
|
|
|
_trigger: Trigger<Pointer<Pressed>>,
|
|
|
|
_event: On<Pointer<Pressed>>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
bird: Single<Entity, With<Bird>>,
|
|
|
|
bird: Single<Entity, With<Bird>>,
|
|
|
|
curr: Res<State<PlayerState>>,
|
|
|
|
curr: Res<State<PlayerState>>,
|
|
|
|
@ -865,7 +865,7 @@ fn flap_button(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let e = *bird;
|
|
|
|
let e = *bird;
|
|
|
|
debug!("Flapping {:?}", e);
|
|
|
|
debug!("Flapping {:?}", e);
|
|
|
|
commands.trigger_targets(Flap, e);
|
|
|
|
commands.event_targets(Flap, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Pause the game when the player presses "Escape"
|
|
|
|
/// Pause the game when the player presses "Escape"
|
|
|
|
@ -877,21 +877,21 @@ fn un_pause_game(mut next: ResMut<NextState<PlayerState>>) {
|
|
|
|
next.set(PlayerState::Alive);
|
|
|
|
next.set(PlayerState::Alive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Component, Clone, Event)]
|
|
|
|
#[derive(Component, Clone, Message)]
|
|
|
|
struct Flap;
|
|
|
|
struct Flap;
|
|
|
|
|
|
|
|
|
|
|
|
// Observer for flapping
|
|
|
|
// Observer for flapping
|
|
|
|
fn flap(
|
|
|
|
fn flap(
|
|
|
|
trigger: Trigger<Flap>,
|
|
|
|
event: On<Flap>,
|
|
|
|
mut bird: Query<&mut ExternalImpulse, With<Bird>>,
|
|
|
|
mut bird: Query<&mut ExternalImpulse, With<Bird>>,
|
|
|
|
mut flaps: ResMut<Flaps>,
|
|
|
|
mut flaps: ResMut<Flaps>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
debug!("real flap for {:?}", trigger.target());
|
|
|
|
debug!("real flap for {:?}", event.entity);
|
|
|
|
// Increment flap stat
|
|
|
|
// Increment flap stat
|
|
|
|
flaps.0 += 1;
|
|
|
|
flaps.0 += 1;
|
|
|
|
|
|
|
|
|
|
|
|
// Flap birds wings
|
|
|
|
// Flap birds wings
|
|
|
|
if let Ok(mut f) = bird.get_mut(trigger.target()) {
|
|
|
|
if let Ok(mut f) = bird.get_mut(event.entity) {
|
|
|
|
f.apply_impulse(Vec2::Y * 5000.0 + Vec2::X * 1000.0);
|
|
|
|
f.apply_impulse(Vec2::Y * 5000.0 + Vec2::X * 1000.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -916,7 +916,7 @@ fn flap_kb(
|
|
|
|
|
|
|
|
|
|
|
|
birds.iter().for_each(|e| {
|
|
|
|
birds.iter().for_each(|e| {
|
|
|
|
debug!("Flapping {:?}", e);
|
|
|
|
debug!("Flapping {:?}", e);
|
|
|
|
commands.trigger_targets(Flap, e);
|
|
|
|
commands.event_targets(Flap, e);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1138,8 +1138,8 @@ impl Display for Deaths {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn manage_score(
|
|
|
|
fn manage_score(
|
|
|
|
mut start: EventReader<CollisionStarted>,
|
|
|
|
mut start: MessageReader<CollisionStarted>,
|
|
|
|
mut end: EventReader<CollisionEnded>,
|
|
|
|
mut end: MessageReader<CollisionEnded>,
|
|
|
|
state: Res<State<PlayerState>>,
|
|
|
|
state: Res<State<PlayerState>>,
|
|
|
|
hitboxes: Query<&Batch, With<Hitbox>>,
|
|
|
|
hitboxes: Query<&Batch, With<Hitbox>>,
|
|
|
|
mut score: ResMut<Score>,
|
|
|
|
mut score: ResMut<Score>,
|
|
|
|
@ -1182,8 +1182,8 @@ fn manage_score(
|
|
|
|
/// Finally we iterate over all entities with the old batch ID and upsert the new batch ID
|
|
|
|
/// Finally we iterate over all entities with the old batch ID and upsert the new batch ID
|
|
|
|
/// This includes root batch entities as well as pipes and hitboxes
|
|
|
|
/// This includes root batch entities as well as pipes and hitboxes
|
|
|
|
fn move_batches(
|
|
|
|
fn move_batches(
|
|
|
|
mut start: EventReader<CollisionStarted>,
|
|
|
|
mut start: MessageReader<CollisionStarted>,
|
|
|
|
mut end: EventReader<CollisionEnded>,
|
|
|
|
mut end: MessageReader<CollisionEnded>,
|
|
|
|
hitboxes: Query<Entity, With<Hitbox>>,
|
|
|
|
hitboxes: Query<Entity, With<Hitbox>>,
|
|
|
|
batches: Query<(Entity, &Batch)>,
|
|
|
|
batches: Query<(Entity, &Batch)>,
|
|
|
|
state: Res<State<PlayerState>>,
|
|
|
|
state: Res<State<PlayerState>>,
|
|
|
|
|