Skip to content

Commit

Permalink
feat: Rendering the MAP
Browse files Browse the repository at this point in the history
the cubes represent all.
  • Loading branch information
mdwmage committed May 21, 2024
1 parent 106ac13 commit e114ecd
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/screen/map.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{entities::Tile, Call};
use macroquad::{
color::{BEIGE, BROWN, SKYBLUE},
shapes::{draw_rectangle, draw_rectangle_lines},
window::{screen_height, screen_width},
color::{BROWN, SKYBLUE},
shapes::draw_rectangle,
};
use serde::Deserialize;
use std::fs;
Expand All @@ -11,24 +10,13 @@ use std::fs;
pub struct Map {
pub name: String,
pub hi_score: u32,
pub width: u32,
pub height: u32,
pub tiles: Vec<Vec<Tile>>,
}

impl Map {
pub fn new(name: &str, hi_score: u32, width: u32, height: u32) -> Self {
Map {
name: name.to_owned(),
hi_score,
width,
height,
tiles: vec![vec![]],
}
}
pub fn render(&self) {
let mut x = screen_width() - self.width as f32;
let mut y = screen_height() - self.height as f32;
let mut x = 0.0;
let mut y = 0.0;

for column in &self.tiles {
for tile in column {
Expand All @@ -40,7 +28,7 @@ impl Map {
y += 100.0;
}
x += 100.0;
y = screen_height() - self.height as f32;
y = 0.0;
}
}
}
Expand All @@ -55,3 +43,10 @@ pub fn parse_config(path: &str) -> Map {
let config = fs::read_to_string(path).expect("Couldn't read config");
toml::from_str(&config).unwrap()
}

pub fn check_tile(tile: &Tile) {
match tile {
Tile::Log => (),
Tile::Water => println!("wet :("),
}
}

0 comments on commit e114ecd

Please sign in to comment.