Skip to content

Commit

Permalink
chore: Bump to v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PraxTube committed Jan 10, 2024
1 parent 21ac16b commit 84d39d0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "insta-kill"
version = "0.1.1"
version = "0.1.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
23 changes: 22 additions & 1 deletion src/ui/game_over.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,31 @@ fn spawn_player_score(commands: &mut Commands, font: Handle<Font>, score: u32) -
commands.spawn(text_bundle).id()
}

fn spawn_restart_text(commands: &mut Commands, font: Handle<Font>) -> Entity {
let text = format!("ESC to skip and restart");
let text_style = TextStyle {
font,
font_size: 30.0,
color: Color::WHITE,
};
let text_bundle = TextBundle::from_sections([TextSection::new(text, text_style.clone())]);
commands
.spawn(text_bundle)
.insert(Style {
margin: UiRect {
top: Val::Px(100.0),
..default()
},
..default()
})
.id()
}

fn spawn_text(commands: &mut Commands, font: Handle<Font>, score: u32) {
let title_text = spawn_title(commands, font.clone());
let score_text = spawn_player_score(commands, font.clone(), score);
let input_field = spawn_text_field(commands, font.clone());
let restart_text = spawn_restart_text(commands, font.clone());

commands
.spawn((
Expand All @@ -84,7 +105,7 @@ fn spawn_text(commands: &mut Commands, font: Handle<Font>, score: u32) {
..default()
},
))
.push_children(&[title_text, score_text, input_field]);
.push_children(&[title_text, score_text, input_field, restart_text]);
}

fn spawn_game_over_screen(
Expand Down
18 changes: 18 additions & 0 deletions src/ui/leaderboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use futures_lite::future;
use bevy::{
prelude::*,
tasks::{block_on, AsyncComputeTaskPool, Task},
utils::futures::now_or_never,
};

use crate::{
Expand Down Expand Up @@ -199,6 +200,23 @@ fn handle_post_task(mut commands: Commands, mut tasks: Query<(Entity, &mut PostD
}
}

fn drop_all_tasks(
mut commands: Commands,
mut get_tasks: Query<(Entity, &mut FetchData), Without<PostData>>,
mut post_tasks: Query<(Entity, &mut PostData), Without<FetchData>>,
) {
for (entity, mut task) in &mut get_tasks {
now_or_never(&mut task.0);
commands.entity(entity).remove::<FetchData>();
commands.entity(entity).despawn_recursive();
}
for (entity, mut task) in &mut post_tasks {
now_or_never(&mut task.0);
commands.entity(entity).remove::<PostData>();
commands.entity(entity).despawn_recursive();
}
}

fn trigger_loading(
mut next_state: ResMut<NextState<GameOverState>>,
mut ev_submitted_text_input: EventReader<SubmittedTextInput>,
Expand Down
2 changes: 1 addition & 1 deletion src/world/restart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn initiate_restart_from_leaderboard(
mut next_state: ResMut<NextState<GameState>>,
player_input: Res<PlayerInput>,
) {
if player_input.restart {
if player_input.restart || player_input.escape {
next_state.set(GameState::Restart);
}
}
Expand Down

0 comments on commit 84d39d0

Please sign in to comment.