Random furnitur skeleton
This commit is contained in:
parent
c5ac0b39b2
commit
a614cd0644
1 changed files with 35 additions and 20 deletions
|
@ -18,12 +18,14 @@ enum RoomType {
|
||||||
SleepingRoom
|
SleepingRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tile = (Vec2, Vec2, Furniture); //(pos, size, furniture)
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Room {
|
pub struct Room {
|
||||||
room_type: RoomType,
|
room_type: RoomType,
|
||||||
pub size: (u8, u8), //(width, height)
|
pub size: (u8, u8), //(width, height)
|
||||||
pub grid: Grid,
|
pub grid: Grid,
|
||||||
furnitures: Vec<(Vec2, Vec2, Furniture)> //(pos, size, furniture)
|
furnitures: Vec<Tile>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RoomType {
|
impl RoomType {
|
||||||
|
@ -44,25 +46,7 @@ impl Room {
|
||||||
let room_type = RoomType::random();
|
let room_type = RoomType::random();
|
||||||
let size = Self::random_size(&room_type);
|
let size = Self::random_size(&room_type);
|
||||||
|
|
||||||
let mut furnitures = Vec::new();
|
let furnitures = Self::random_room_furniture(&room_type, size, ctx);
|
||||||
|
|
||||||
if room_type == RoomType::Kitchen {
|
|
||||||
furnitures.push((
|
|
||||||
vec2(0.0, 0.0),
|
|
||||||
vec2(1.0, 2.0),
|
|
||||||
Furniture::new("kitchen", "fridge", ctx)
|
|
||||||
));
|
|
||||||
furnitures.push((
|
|
||||||
vec2(1.0, 0.0),
|
|
||||||
vec2(1.0, 1.0),
|
|
||||||
Furniture::new("kitchen", "dishwasher", ctx)
|
|
||||||
));
|
|
||||||
furnitures.push((
|
|
||||||
vec2(1.0, 1.0),
|
|
||||||
vec2(0.75, 0.75),
|
|
||||||
Furniture::new("kitchen", "blender", ctx)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Room {
|
Room {
|
||||||
room_type,
|
room_type,
|
||||||
|
@ -73,6 +57,9 @@ impl Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn random_size(room_type: &RoomType) -> (u8, u8) {
|
fn random_size(room_type: &RoomType) -> (u8, u8) {
|
||||||
|
//Kitchen + Living Room 5-8
|
||||||
|
//Bath + sleepingroom 4-6
|
||||||
|
//Toilet 2-3
|
||||||
match room_type {
|
match room_type {
|
||||||
RoomType::Kitchen | RoomType::LivingRoom => (random_i32(5, 8) as u8, 3),
|
RoomType::Kitchen | RoomType::LivingRoom => (random_i32(5, 8) as u8, 3),
|
||||||
RoomType::Bath | RoomType::SleepingRoom => (random_i32(4, 6) as u8, 3),
|
RoomType::Bath | RoomType::SleepingRoom => (random_i32(4, 6) as u8, 3),
|
||||||
|
@ -80,6 +67,34 @@ impl Room {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn random_room_furniture(room_type: &RoomType, size: (u8, u8), ctx: &mut EngineContext<'_>) -> Vec<Tile> {
|
||||||
|
let mut furnitures = Vec::new();
|
||||||
|
let width = size.0;
|
||||||
|
|
||||||
|
match room_type {
|
||||||
|
RoomType::Kitchen => {
|
||||||
|
furnitures.push((
|
||||||
|
vec2(0.0, 0.0),
|
||||||
|
vec2(1.0, 2.0),
|
||||||
|
Furniture::new("kitchen", "fridge", ctx)
|
||||||
|
));
|
||||||
|
furnitures.push((
|
||||||
|
vec2(1.0, 0.0),
|
||||||
|
vec2(1.0, 1.0),
|
||||||
|
Furniture::new("kitchen", "dishwasher", ctx)
|
||||||
|
));
|
||||||
|
furnitures.push((
|
||||||
|
vec2(1.0, 1.0),
|
||||||
|
vec2(0.75, 0.75),
|
||||||
|
Furniture::new("kitchen", "blender", ctx)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
furnitures
|
||||||
|
}
|
||||||
|
|
||||||
fn create_grid(width: u8, height: u8) -> Grid {
|
fn create_grid(width: u8, height: u8) -> Grid {
|
||||||
error!("START GRID CREATION!");
|
error!("START GRID CREATION!");
|
||||||
let left_border = width as f32 / 2.0;
|
let left_border = width as f32 / 2.0;
|
||||||
|
|
Loading…
Reference in a new issue