Merge pull request #36 from Ewpratten/ewpratten/better_sampling

F3 for DEBUG
This commit is contained in:
Evan Pratten 2022-04-03 16:45:43 -04:00 committed by GitHub
commit 76aede470b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 6 deletions

View File

@ -29,6 +29,7 @@ pub enum MenuStateSignal {
pub struct MainMenu {
pub has_updated_discord_rpc: bool,
volume_percentage: f32,
show_debug_info: bool,
}
impl MainMenu {
@ -42,6 +43,7 @@ impl MainMenu {
Self {
has_updated_discord_rpc: false,
volume_percentage: game_settings.volume.unwrap_or(0.5),
show_debug_info: false,
}
}
@ -78,9 +80,21 @@ impl MainMenu {
let mouse_x = draw.get_mouse_x();
let mouse_y = draw.get_mouse_y();
//TODO Errase later
draw.draw_text(&mouse_x.to_string(), 20, 5, 20, Color::BLACK);
draw.draw_text(&mouse_y.to_string(), 70, 5, 20, Color::BLACK);
// Optionally display debug info
if draw.is_key_pressed(KeyboardKey::KEY_F3) {
self.show_debug_info = !self.show_debug_info;
}
if self.show_debug_info {
// Draw FPS and mouse location
draw.draw_fps(10, 10);
draw.draw_text(
format!("Mouse position: ({}, {})", mouse_x, mouse_y).as_str(),
10,
30,
20,
Color::GREEN,
);
}
//Screen Size
let window_height = draw.get_screen_height();

View File

@ -17,7 +17,9 @@ use crate::{
use super::main_menu::MenuStateSignal;
#[derive(Debug)]
pub struct PauseMenu {}
pub struct PauseMenu {
show_debug_info: bool,
}
impl PauseMenu {
/// Construct a new `PauseMenu`
@ -27,7 +29,9 @@ impl PauseMenu {
constants: &ProjectConstants,
game_settings: &mut PersistentGameSettings,
) -> Self {
Self {}
Self {
show_debug_info: false,
}
}
pub async fn render_pause_menu_frame(
@ -45,6 +49,26 @@ impl PauseMenu {
// Clear the screen
draw.clear_background(Color::WHITE);
//Obtain mouse position
let mouse_x = draw.get_mouse_x();
let mouse_y = draw.get_mouse_y();
// Optionally display debug info
if draw.is_key_pressed(KeyboardKey::KEY_F3) {
self.show_debug_info = !self.show_debug_info;
}
if self.show_debug_info {
// Draw FPS and mouse location
draw.draw_fps(10, 10);
draw.draw_text(
format!("Mouse position: ({}, {})", mouse_x, mouse_y).as_str(),
10,
30,
20,
Color::GREEN,
);
}
// Title
draw.draw_text("Paused", 100, 90, 60, Color::BLACK);

View File

@ -24,6 +24,7 @@ pub struct PlayableScene {
last_update: SystemTime,
game_soundtrack: Music,
world_colliders: Vec<WorldSpaceObjectCollider>,
show_debug_info: bool,
}
impl PlayableScene {
@ -62,6 +63,7 @@ impl PlayableScene {
last_update: SystemTime::UNIX_EPOCH,
game_soundtrack,
world_colliders,
show_debug_info: false,
}
}
@ -123,7 +125,7 @@ impl PlayableScene {
// Render the map
self.world_map
.render_map(&mut ctx2d, &self.camera, true, self.player.position);
.render_map(&mut ctx2d, &self.camera, self.show_debug_info, self.player.position);
let player_size =
(constants.tile_size as f32 * constants.player.start_size * self.player.size) as i32;
@ -138,6 +140,26 @@ impl PlayableScene {
}
pub fn draw_ui(&mut self, draw: &mut RaylibDrawHandle, constants: &ProjectConstants) {
// Obtain mouse position
let mouse_x = draw.get_mouse_x();
let mouse_y = draw.get_mouse_y();
// Optionally display debug info
if draw.is_key_pressed(KeyboardKey::KEY_F3) {
self.show_debug_info = !self.show_debug_info;
}
if self.show_debug_info {
// Draw FPS and mouse location
draw.draw_fps(10, 10);
draw.draw_text(
format!("Mouse position: ({}, {})", mouse_x, mouse_y).as_str(),
10,
30,
20,
Color::GREEN,
);
}
draw.draw_rectangle(draw.get_screen_width() / 2 - 225, 0, 450, 40, Color::WHITE);
draw.draw_text(
"Unregistered HyperCam 2",