Skip to content

Commit

Permalink
Add EmptyReserved blocktype
Browse files Browse the repository at this point in the history
  • Loading branch information
iMilchshake committed May 15, 2024
1 parent 1afa768 commit a2997e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const CHUNK_SIZE: usize = 5;
#[derive(Debug, Clone, PartialEq)]
pub enum BlockType {
Empty,
/// Empty Block that should not be overwritten
EmptyReserved,
Hookable,
Freeze,
Spawn,
Expand All @@ -20,9 +22,8 @@ impl BlockType {
/// maps BlockType to tw game layer id for map export
pub fn to_tw_game_id(&self) -> u8 {
match self {
BlockType::Empty => 0,
BlockType::Hookable => 1,
BlockType::Platform => 1,
BlockType::Empty | BlockType::EmptyReserved => 0,
BlockType::Hookable | BlockType::Platform => 1,
BlockType::Freeze => 9,
BlockType::Spawn => 192,
BlockType::Start => 33,
Expand Down Expand Up @@ -178,13 +179,22 @@ impl Map {
let platform_margin: i32 = platform_margin.to_i32().unwrap();

// carve room
self.set_area(
self.set_area_border(
&pos.shifted_by(-room_size, -room_size)?,
&pos.shifted_by(room_size, room_size)?,
&BlockType::Empty,
&Overwrite::Force,
);

let inner_room_size = room_size - 1;
assert!(inner_room_size > 0);
self.set_area(
&pos.shifted_by(-inner_room_size, -inner_room_size)?,
&pos.shifted_by(inner_room_size, inner_room_size)?,
&BlockType::EmptyReserved,
&Overwrite::Force,
);

// set platform
self.set_area(
&pos.shifted_by(-(room_size - platform_margin), room_size - 2)?,
Expand Down
3 changes: 2 additions & 1 deletion src/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ fn blocktype_to_color(value: &BlockType) -> Color {
match value {
BlockType::Hookable => colors::BROWN,
BlockType::Freeze => Color::new(0.0, 0.0, 0.0, 0.8),
BlockType::Empty => Color::new(0.0, 0.0, 0.0, 0.1),
BlockType::Empty => Color::new(0.0, 0.0, 0.0, 0.0),
BlockType::EmptyReserved => Color::new(0.3, 0.0, 0.0, 0.1),
BlockType::Finish => Color::new(1.0, 0.1, 0.1, 0.8),
BlockType::Start => Color::new(0.1, 1.0, 0.1, 0.8),
BlockType::Spawn => Color::new(0.5, 0.5, 0.0, 0.8),
Expand Down

0 comments on commit a2997e8

Please sign in to comment.