From 57c5aaa71471092c3e6e31106b101a76aa0781a1 Mon Sep 17 00:00:00 2001 From: Si Bartha Date: Sat, 2 Apr 2022 16:05:14 -0400 Subject: [PATCH] Poo Text --- game/dist/project-constants.json | 3 +- game/game_logic/src/project_constants.rs | 3 ++ .../src/scenes/player_interaction.rs | 52 +++++++++++-------- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/game/dist/project-constants.json b/game/dist/project-constants.json index cd2d0e59..46f8c02e 100644 --- a/game/dist/project-constants.json +++ b/game/dist/project-constants.json @@ -20,6 +20,7 @@ "player": { "max_velocity": 3, "acceleration": 2, - "deceleration": 1 + "deceleration": 1, + "start_size": 0.8 } } diff --git a/game/game_logic/src/project_constants.rs b/game/game_logic/src/project_constants.rs index 0797baf2..6df497d3 100644 --- a/game/game_logic/src/project_constants.rs +++ b/game/game_logic/src/project_constants.rs @@ -40,6 +40,9 @@ pub struct PlayerConstants { /// Deceleration, tiles per second per second pub deceleration: u32, + + /// Starting size of player in tiles + pub start_size: f32, } /// This structure is filled with the contents of `dist/project-constants.json` at runtime diff --git a/game/game_logic/src/scenes/player_interaction.rs b/game/game_logic/src/scenes/player_interaction.rs index cef3186e..294278c7 100644 --- a/game/game_logic/src/scenes/player_interaction.rs +++ b/game/game_logic/src/scenes/player_interaction.rs @@ -81,34 +81,44 @@ impl PlayableScene { // Clear the screen draw.clear_background(Color::WHITE); + + self.draw_world(&mut draw, constants); - { - // Begin camera mode - let mut ctx2d = draw.begin_mode2D(self.camera); + self.draw_ui(&mut draw, constants); + } - // Render the map - self.world_map.render_map(&mut ctx2d, &self.camera, true); - } + pub fn draw_world( + &mut self, + draw: &mut RaylibDrawHandle, + constants: &ProjectConstants, + ) { + // Begin camera mode + let mut ctx2d = draw.begin_mode2D(self.camera); - for i in 0..100 { - for j in 0..100 { - draw.draw_rectangle( - constants.tile_size as i32 * (i * 2), - constants.tile_size as i32 * (j * 2) * -1, - constants.tile_size as i32, - constants.tile_size as i32, - Color::RED - ) - } - } - - draw.draw_rectangle( + // Render the map + self.world_map.render_map(&mut ctx2d, &self.camera, true); + + ctx2d.draw_rectangle( self.player.position[0] as i32, self.player.position[1] as i32 * -1, - (constants.tile_size as f32 * self.player.size) as i32, - (constants.tile_size as f32 * self.player.size) as i32, + (constants.tile_size as f32 * constants.player.start_size * self.player.size) as i32, + (constants.tile_size as f32 * constants.player.start_size * self.player.size) as i32, Color::GREEN ); + + } + + pub fn draw_ui( + &mut self, + draw: &mut RaylibDrawHandle, + constants: &ProjectConstants, + ) { + draw.draw_fps(0, 0); + draw.draw_text( + "Poo Text", + 10, 100, 144, + Color::BROWN + ); } // Physics