Pretty hacky but still a wip

This commit is contained in:
wm-c 2021-04-24 15:18:39 -04:00
parent 2844e5ac0b
commit 2628c0d740
2 changed files with 11 additions and 16 deletions

View File

@ -63,7 +63,7 @@ impl Screen for InGameScreen {
} }
// Only render shop in shop period, otherwise allow player movement
if draw_handle.get_time() - game_core.last_state_change_time >= 0.05 if draw_handle.get_time() - game_core.last_state_change_time >= 0.05
&& self.current_state == InGameState::BUYING{ && self.current_state == InGameState::BUYING{

View File

@ -36,10 +36,13 @@ impl Shop {
} }
} }
// Creates all the items
pub fn create_items(&mut self, screen_dimension: Vector2){ pub fn create_items(&mut self, screen_dimension: Vector2){
// gets every item.. hacky
let items = ShopItems::get_inital_items(); let items = ShopItems::get_inital_items();
// sets sizes any random number is just a number I think looks good
let screen_width = screen_dimension.x as f32; let screen_width = screen_dimension.x as f32;
let screen_height = screen_dimension.y as f32; let screen_height = screen_dimension.y as f32;
@ -54,11 +57,13 @@ impl Shop {
for box_num in 0..4 { for box_num in 0..4 {
let x_pose = start_width + box_width * box_num as f32; let x_pose = start_width + box_width * box_num as f32;
// adds an item struct to the item list
item_vec.push(Item{ item_vec.push(Item{
x_pose: (x_pose as i32), x_pose: (x_pose as i32),
y_pose: (draw_height as i32), y_pose: (draw_height as i32),
width: (box_width as i32), width: (box_width as i32),
height: (box_height as i32), height: (box_height as i32),
// Crazy hacky but this gets the data from the enum
cost: (ShopItems::get_cost(&items.get(box_num).unwrap())), cost: (ShopItems::get_cost(&items.get(box_num).unwrap())),
level: (ShopItems::get_level(&items.get(box_num).unwrap())), level: (ShopItems::get_level(&items.get(box_num).unwrap())),
name: (ShopItems::get_name(&items.get(box_num).unwrap())), name: (ShopItems::get_name(&items.get(box_num).unwrap())),
@ -74,7 +79,8 @@ impl Shop {
pub fn render_shop( pub fn render_shop(
draw_handle: &mut RaylibDrawHandle, draw_handle: &mut RaylibDrawHandle,
game_core: &mut GameCore, game_core: &mut GameCore,
inGameScreen: &mut InGameScreen) { inGameScreen: &mut InGameScreen,
) {
@ -83,22 +89,11 @@ pub fn render_shop(
inGameScreen.current_state = InGameState::SWIMMING; inGameScreen.current_state = InGameState::SWIMMING;
} }
// Get Screen dimemensions
let screen_width = draw_handle.get_screen_width() as f32;
let screen_height = draw_handle.get_screen_height() as f32;
let box_height = screen_height * 0.15;
let box_width = screen_width * 0.1;
let start_width = screen_width - (box_width * 4.0) - 40.0;
let draw_height = screen_height - 20.0 - box_height;
//draw_handle.draw_rectangle(start_index as i32, (screen_height - 20.0 - box_height) as i32, box_width as i32, box_height as i32, Color::BLACK);
// Draws shop boxes // Draws shop boxes
for box_num in 0..4 { for item in inGameScreen.shop.shop_items.iter() {
let x_pose = start_width + box_width * box_num as f32; // Draws in accordance to the struct
draw_handle.draw_rectangle(item.x_pose, item.y_pose, item.width, item.height, Color::BLACK);
draw_handle.draw_rectangle_lines(x_pose as i32, draw_height as i32, box_width as i32, box_height as i32, Color::BLACK);
} }