From 166e83ad069206d1f40a9a551bd787fce9cee034 Mon Sep 17 00:00:00 2001 From: Si Bartha Date: Sat, 2 Apr 2022 00:06:46 -0400 Subject: [PATCH] Drawing a Box --- game/dist/project-constants.json | 3 ++- game/game_logic/src/model/player.rs | 4 +++- game/game_logic/src/project_constants.rs | 3 +++ game/game_logic/src/scenes/player_interaction.rs | 10 ++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/game/dist/project-constants.json b/game/dist/project-constants.json index 3064e0eb..6f9303c7 100644 --- a/game/dist/project-constants.json +++ b/game/dist/project-constants.json @@ -5,6 +5,7 @@ 720 ], "target_fps": 60, + "tile_size": 128, "discord": { "app_id": 954413081918857276, "artwork": { @@ -16,4 +17,4 @@ "details.main_menu": "In the main menu" } } -} \ No newline at end of file +} diff --git a/game/game_logic/src/model/player.rs b/game/game_logic/src/model/player.rs index 2bb87f3e..69a7fe9f 100644 --- a/game/game_logic/src/model/player.rs +++ b/game/game_logic/src/model/player.rs @@ -5,6 +5,7 @@ use nalgebra as na; pub struct Player { pub position: na::Vector2, pub velocity: na::Vector2, + pub size: f32, } impl Player { @@ -14,7 +15,8 @@ impl Player { Self { position, velocity: na::Vector2::zeros(), + size: 1.0, } } -} \ No newline at end of file +} diff --git a/game/game_logic/src/project_constants.rs b/game/game_logic/src/project_constants.rs index 4350a297..b0a32061 100644 --- a/game/game_logic/src/project_constants.rs +++ b/game/game_logic/src/project_constants.rs @@ -42,4 +42,7 @@ pub struct ProjectConstants { /// The target framerate of the game pub target_fps: u32, + + /// The size of the game tiles + pub tile_size: u8, } diff --git a/game/game_logic/src/scenes/player_interaction.rs b/game/game_logic/src/scenes/player_interaction.rs index db34e0bd..fb7e25e9 100644 --- a/game/game_logic/src/scenes/player_interaction.rs +++ b/game/game_logic/src/scenes/player_interaction.rs @@ -61,7 +61,17 @@ impl PlayableScene { // Clear the screen draw.clear_background(Color::WHITE); + draw.draw_rectangle_lines( + 0, + 0, + (constants.tile_size as f32 * self.player.size) as i32, + (constants.tile_size as f32 * self.player.size) as i32, + Color::GREEN + ); + // TODO: Render stuff // self.player. } } + +