diff --git a/src/logic/ingame/hud.rs b/src/logic/ingame/hud.rs index e067cba..3f576d0 100644 --- a/src/logic/ingame/hud.rs +++ b/src/logic/ingame/hud.rs @@ -17,25 +17,25 @@ pub fn render_hud( let progress = (dist_from_start_to_end - dist_from_player_to_end) / dist_from_start_to_end; // Render the base of the progress bar - let progress_bar_rect = Rectangle { - x: 20.0, - y: (window_center.y * 2.0) - 20.0 - 40.0, - width: (window_center.x * 2.0) - 40.0, - height: 40.0, - }; - draw_handle.draw_rectangle_rec(progress_bar_rect, Color::BLUE); - draw_handle.draw_rectangle_lines_ex(progress_bar_rect, 6, Color::WHITE); + // let progress_bar_rect = Rectangle { + // x: 20.0, + // y: (window_center.y * 2.0) - 20.0 - 40.0, + // width: (window_center.x * 2.0) - 40.0, + // height: 40.0, + // }; + // draw_handle.draw_rectangle_rec(progress_bar_rect, Color::BLUE); + // draw_handle.draw_rectangle_lines_ex(progress_bar_rect, 6, Color::WHITE); - // Render the slider of the progress bar - let progress_bar_slider = Rectangle { - x: (((window_center.x * 2.0) - 40.0) * progress.abs().clamp(0.0, 1.0)) + 10.0, - y: (window_center.y * 2.0) - 20.0 - 50.0, - width: 40.0, - height: 60.0, - }; - draw_handle.draw_rectangle_rec(progress_bar_slider, Color::BLUE); - //TODO: This causes a render bug - draw_handle.draw_rectangle_lines_ex(progress_bar_slider, 6, Color::WHITE); + // // Render the slider of the progress bar + // let progress_bar_slider = Rectangle { + // x: (((window_center.x * 2.0) - 40.0) * progress.abs().clamp(0.0, 1.0)) + 10.0, + // y: (window_center.y * 2.0) - 20.0 - 50.0, + // width: 40.0, + // height: 60.0, + // }; + // draw_handle.draw_rectangle_rec(progress_bar_slider, Color::BLUE); + // //TODO: This causes a render bug + // draw_handle.draw_rectangle_lines_ex(progress_bar_slider, 6, Color::WHITE); // TODO: Breath bar // TODO: Boost bar diff --git a/src/logic/ingame/mod.rs b/src/logic/ingame/mod.rs index 3934e09..7ef15cc 100644 --- a/src/logic/ingame/mod.rs +++ b/src/logic/ingame/mod.rs @@ -47,7 +47,7 @@ impl Screen for InGameScreen { game_core: &mut GameCore, ) -> Option { // Clear frame - draw_handle.clear_background(Color::RAYWHITE); + draw_handle.clear_background(Color::BLUE); // Handle the pause menu being opened if draw_handle.is_key_pressed(KeyboardKey::KEY_ESCAPE) { diff --git a/src/logic/ingame/playerlogic.rs b/src/logic/ingame/playerlogic.rs index 76958e4..6dc036e 100644 --- a/src/logic/ingame/playerlogic.rs +++ b/src/logic/ingame/playerlogic.rs @@ -1,6 +1,9 @@ use raylib::prelude::*; -use crate::gamecore::GameCore; +use crate::{ + gamecore::GameCore, + pallette::{TRANSLUCENT_WHITE_128, TRANSLUCENT_WHITE_64}, +}; const NORMAL_PLAYER_SPEED: i32 = 4; const BOOST_PLAYER_SPEED: i32 = NORMAL_PLAYER_SPEED * 2; @@ -59,6 +62,25 @@ pub fn render_player(context_2d: &mut RaylibMode2D, game_core: // Convert the player direction to a rotation let player_rotation = Vector2::zero().angle_to(player.direction); + // Render the player's boost ring + // This functions both as a breath meter, and as a boost meter + let boost_ring_max_radius = player.size.x + 5.0; + context_2d.draw_circle( + player.position.x as i32, + player.position.y as i32, + boost_ring_max_radius * player.boost_percent, + TRANSLUCENT_WHITE_64, + ); + context_2d.draw_ring( + player.position, + boost_ring_max_radius - 2.0, + boost_ring_max_radius + 2.0, + 0, + (360.0 * player.breath_percent) as i32, + 0, + TRANSLUCENT_WHITE_128, + ); + // TODO: tmp rect context_2d.draw_rectangle_pro( Rectangle { diff --git a/src/main.rs b/src/main.rs index 65d79ad..50cc74d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ mod logic; mod resources; mod player; mod world; +mod pallette; use gamecore::{GameCore, GameState}; use lib::{utils::profiler::GameProfiler, wrappers::audio::player::AudioPlayer}; diff --git a/src/pallette.rs b/src/pallette.rs index e69de29..2517a57 100644 --- a/src/pallette.rs +++ b/src/pallette.rs @@ -0,0 +1,15 @@ +use raylib::color::Color; + +pub const TRANSLUCENT_WHITE_128: Color = Color { + r: 255, + g: 255, + b: 255, + a: 128, +}; + +pub const TRANSLUCENT_WHITE_64: Color = Color { + r: 255, + g: 255, + b: 255, + a: 64, +}; \ No newline at end of file diff --git a/src/player.rs b/src/player.rs index a455e9b..4ce8bfe 100644 --- a/src/player.rs +++ b/src/player.rs @@ -20,7 +20,7 @@ impl Player { x: 11.0 * 4.0, y: 21.0 * 4.0 }, - breath_percent: 1.0, + breath_percent: 0.5, ..Default::default() }