Merge pull request #69 from Ewpratten/level-select-title

fix level select title
This commit is contained in:
Evan Pratten 2021-10-04 08:23:40 -07:00 committed by GitHub
commit dd16a0debc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,7 @@ pub struct LevelSelectScreen {
is_btm_pressed: bool,
selected_level: Option<usize>,
visible_levels: usize,
counter: i32,
}
impl LevelSelectScreen {
@ -35,6 +36,7 @@ impl LevelSelectScreen {
is_btm_pressed: false,
selected_level: None,
visible_levels: 0,
counter: 0,
}
}
}
@ -73,6 +75,8 @@ impl Action<Scenes, ScreenError, GameContext> for LevelSelectScreen {
trace!("execute() called on LevelSelectScreen");
self.render_screen_space(&mut context.renderer.borrow_mut(), &context.config);
self.counter += 1;
if let Some(level) = self.selected_level {
// Play the sound
context
@ -110,6 +114,7 @@ impl Action<Scenes, ScreenError, GameContext> for LevelSelectScreen {
debug!("Finished LevelSelectScreen");
self.selected_level = None;
self.is_btm_pressed = false;
self.counter = 0;
Ok(())
}
}
@ -140,13 +145,28 @@ impl ScreenSpaceRender for LevelSelectScreen {
let mouse_pressed: bool = raylib.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON);
//Render the title
raylib.draw_rgb_split_text(
Vector2::new(40.0, 80.0),
"Level Select",
70,
true,
Color::WHITE,
);
let timer: i32 = get_random_value(50, 400);
if self.counter > timer {
raylib.draw_rgb_split_text(
Vector2::new(40.0, 80.0),
"[Level Select]",
70,
true,
Color::WHITE,
);
}
if self.counter > timer + 20 {
self.counter = 0;
}
else {
raylib.draw_rgb_split_text(
Vector2::new(40.0, 80.0),
"[Level Select]",
70,
false,
Color::WHITE,
);
}
// Render the levels
for level in 0..self.visible_levels {