Skip to content

Commit

Permalink
Merge pull request #15 from claby2/fix-start-delay-position
Browse files Browse the repository at this point in the history
Fix start delay position
  • Loading branch information
virchau13 authored Mar 4, 2022
2 parents f768b1a + e5dcb0b commit f6c093b
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 24 deletions.
52 changes: 52 additions & 0 deletions assets/levels/maze.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# * . . . . . . . . . # # . . . . . . # # . . . . . . # # . . . . . . . . . . . . . . # # . . . . #
# . . . . . . . . . . # # . . . . . . # # . . . . . . # # . . . . . . . . . . . . . . # # . . . . #
# . . # # # # # # . . # # . . # # # # # # . . # # # # # # . . # # # # # # # # # # # # # # . . # # #
# . . # # # # # # . . # # . . # # # # # # . . # # # # # # . . # # # # # # # # # # # # # # . . # # #
# . . . . . . # # . . . . . . . . . . . . . . . . . . . . . . . . . . M # . . . . . . . . . . . . #
# . . . . . . # # . . . . . . . . . . . . . . . . . . . . . . . . . . M # . . . . . . . . . . . . #
# . . # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # # # # # . . # # . . # # # # # # #
# . . # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # # # # # . . # # . . # # # # # # #
# . . # # . . # # . . # # . . # # . . # # . . . . . . # # . . . . . . . . . . # # . . . . . . # # #
# M M # # . . # # . . # # . . # # . . # # . . . . . . # # . . . . . . . . . . # # . . . . . . # # #
# # # # # # # # # . . # # . . # # # # # # # # # # # # # # . . # # # # # # . . # # # # # # # # # # #
# # # # # # # # # . . # # . . # # # # # # # # # # # # # # . . # # # # # # . . # # # # # # # # # # #
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # # . . # # . . . . . . . . #
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # # . . # # . . . . . . . . #
# . . # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # # # # # . . # # # # # # #
# . . # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # # # # # . . # # # # # # #
# . . # # . . . . . . # # . . . . . . M # . . # # . . . . . . . . . . . . . . . . . . . . . . . . #
# . . # # . . . . . . # # . . . . . . M # . . # # . . . . . . . . . . . . . . . . . . . . . . . . #
# . . # # . . # # # # # # . . # # . . # # . . # # . . # # . . # # # # # # # # # # # # # # . . # # #
# . . # # . . # # # # # # . . # # . . # # . . # # . . # # . . # # # # # # # # # # # # # # . . # # #
# . . # # . . # # . . . . . . # # . . # # . . # # . . # # . . . . . . M # . . . . . . . . . . . . #
# . . # # . . # # . . . . . . # # . . # # . . # # . . # # . . . . . . M # . . . . . . . . . . . . #
# . . # # . . # # # # # # . . # # . . # # . . # # . . # # . . # # . . # # # # # # # # # # # # # # #
# . . # # . . # # # # # # . T # # . . # # . . # # . . # # . . # # . . # # # # # # # # # # # # # # #
# . . # # . . . . . . M # . T # # . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . . . #
# . . # # . . . . . . M # . T # # . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . . . #
# . . # # # # # # # # # # . . # # . . # # . . # # . . # # . . # # # # # # . . # # . . # # . . # # #
# . . # # # # # # # # # # . . # # . . # # . . # # . . # # . . # # # # # # . . # # . . # # . . # # #
# . . . . . . # # . . . . . . # # . . # # . . # # . . # # . . . . . . . . . . . . . . # # . . # # #
# . . . . . . # # . . . . . . # # . . # # . . # # . . # # . . . . . . . . . . . . . . # # . . # # #
# # # # # . . # # . . # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # . . # # # # # # #
# # # # # . . # # . . # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # . . # # # # # # #
# . . . . . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . . . . . # # #
# . . . . . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . # # . . . . . . # # #
# . . # # . . # # . . # # # # # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # #
# . . # # . . # # . . # # # # # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # # # # # #
# . . # # . . # # . . # M . . . . . . . . . . . . . . . . . . . . . . . . . . # # . . . . . . . . #
# . . # # . . # # . . # M . . . . . . . . . . . . . . . . . . . . . . . . . . # # . . . . . . . . #
# . . # # # # # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # #
# . . # # # # # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # . . # # . . # # # # # # #
# . . # # . . . . . . . . . . # # . . # # G M M M . . # # . . # # . . . . . . . . . . . . . . . . #
# . . # # . . . . . . . . . . # # . . # # G M M M . . # # . . # # . . . . . . . . . . . . . . . . #
# . . # # . . # # # # # # . . # # # # # # # # # # # # # # . . # # . . # # # # # # . . # # # # # # #
# . . # # . . # # # # # # . . # # # # # # # # # # # # # # . . # # . . # # # # # # . . # # # # # # #
# . . # # . . # # . . . . . . # # . . . . . . . . . . . . . . # # . . . . . . # # . . . . . . # # #
# . . # # . . # # . . . . . . # # . . . . . . . . . . . . . . # # . . . . . . # # . . . . . . # # #
# . . # # . . # # . . # # # # # # . . # # . . # # # # # # . . # # # # # # . . # # . . # # . . # # #
# . . # # . . # # . . # # # # # # . . # # . . # # # # # # . . # # # # # # . . # # . . # # . . # # #
# . . # # . . # # . . # # . . . . . . # # . . # # G G G G . . M M M M # # . . # # . . # # . . . . # .
# . . # # . . # # . . # # . . . . . . # # . . # # G G G G . . M M M M # # . . # # . . # # . . . . # .
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
55 changes: 32 additions & 23 deletions src/start_delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy::utils::Duration;
use crate::camera::MainCamera;
use crate::player::Player;
use crate::ui::GameFont;
use crate::world::{spawn_world, GameWorld};
use crate::world::spawn_world;
use crate::AppState;

pub struct StartDelayPlugin;
Expand All @@ -30,47 +30,56 @@ struct CameraSpeed {
}

fn create_delay_timer(mut commands: Commands, font: Res<GameFont>) {
println!("enter create delay state");
commands.spawn_bundle(UiCameraBundle::default());

commands
.spawn_bundle(TextBundle {
.spawn_bundle(NodeBundle {
style: Style {
position_type: PositionType::Absolute,
position: Rect {
top: Val::Percent(45.0),
left: Val::Percent(45.0),
..Rect::default()
},
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..Style::default()
},
text: Text::with_section(
"",
TextStyle {
font: font.get_handle(),
font_size: 50.0,
..TextStyle::default()
},
TextAlignment::default(),
),
..TextBundle::default()
color: Color::NONE.into(),
..NodeBundle::default()
})
.insert(Timer::new(Duration::from_secs(TIMER_SECS as u64), false))
.insert(CameraSpeed { speed: None });
.with_children(|parent| {
parent
.spawn_bundle(TextBundle {
style: Style {
position_type: PositionType::Absolute,
position: Rect {
top: Val::Percent(40.0),
..Rect::default()
},
..Style::default()
},
text: Text::with_section(
"",
TextStyle {
font: font.get_handle(),
font_size: 50.0,
..TextStyle::default()
},
TextAlignment::default(),
),
..TextBundle::default()
})
.insert(Timer::new(Duration::from_secs(TIMER_SECS as u64), false))
.insert(CameraSpeed { speed: None });
});
}

fn update_delay_timer(
mut camera: Query<&mut Transform, With<MainCamera>>,
player_transform: Query<&Transform, (With<Player>, Without<MainCamera>)>,
mut state: ResMut<State<AppState>>,
world: Res<GameWorld>,
time: Res<Time>,
mut text: Query<(&mut Text, &mut Timer, &mut CameraSpeed)>,
) {
let (mut text, mut timer, mut camera_speed) = text.single_mut();
timer.tick(time.delta());
if timer.finished() {
println!("start delay finished");
state.set(AppState::Game).unwrap();
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct GameWorld {
pub layout: Vec<Vec<Option<Tile>>>,
}

pub const LEVELS: [(&'static str, &'static str); 4] = [
pub const LEVELS: [(&'static str, &'static str); 5] = [
("Level 0", include_str!("../assets/levels/level0.tsv")),
("Level 1", include_str!("../assets/levels/level1.tsv")),
(
Expand All @@ -70,6 +70,7 @@ pub const LEVELS: [(&'static str, &'static str); 4] = [
"Drift",
include_str!("../assets/levels/Levels_-_Beeline_-_Drift.tsv"),
),
("Maze", include_str!("../assets/levels/maze.tsv")),
];

impl GameWorld {
Expand Down

0 comments on commit f6c093b

Please sign in to comment.