Add fence to static worldgen #4

Merged
msrd0 merged 3 commits from fence-assets into main 2024-07-06 21:19:25 +00:00
Showing only changes of commit 3a5ae15c41 - Show all commits

View file

@ -28,6 +28,13 @@ pub enum Tile {
bottom: bool
},
Fence {
left: bool,
right: bool,
top: bool,
bottom: bool
},
House {
texture: TextureHandle,
door: bool
@ -71,6 +78,38 @@ impl Tile {
vec![ASSETS.overworld.grass, path_texture]
},
Self::Fence {
left,
right,
top,
bottom
} => {
let path_texture = match (left, right, top, bottom) {
(true, true, false, false) => ASSETS.overworld.fence_horiz,
(false, false, true, true) => ASSETS.overworld.fence_vert,
(true, false, true, false) => ASSETS.overworld.fence_top_left,
(true, false, false, true) => ASSETS.overworld.fence_bottom_left,
(false, true, true, false) => ASSETS.overworld.fence_top_right,
(false, true, false, true) => ASSETS.overworld.fence_bottom_right,
(true, true, true, false)
| (true, true, false, true)
| (true, false, true, true)
| (false, true, true, true) => unimplemented!(),
(true, true, true, true) => unimplemented!(),
(true, false, false, false)
| (false, true, false, false)
| (false, false, true, false)
| (false, false, false, true) => panic!("We don't have no dead ends"),
(false, false, false, false) => panic!("I think you meant grass?!?")
};
vec![ASSETS.overworld.grass, path_texture]
},
Self::House { texture, .. } => {
vec![ASSETS.overworld.grass, *texture]
}
@ -123,15 +162,6 @@ impl Chunk {
// TODO real worldgen
// for the time being we just copy this pre-made house block into the chunk
fn path(left: bool, right: bool, top: bool, bottom: bool) -> Tile {
Tile::Path {
left,
right,
top,
bottom
}
}
fn house(texture: TextureHandle) -> Tile {
Tile::House {
texture,
@ -139,14 +169,42 @@ impl Chunk {
}
}
let path_horiz = path(true, true, false, false);
let path_vert = path(false, false, true, true);
let path_crossing = path(true, true, true, true);
let path_horiz = Tile::Path {
left: true,
right: true,
top: false,
bottom: false
};
let path_vert = Tile::Path {
left: false,
right: false,
top: true,
bottom: true
};
let path_crossing = Tile::Path {
left: true,
right: true,
top: true,
bottom: true
};
let fence_horiz = Tile::Fence {
left: true,
right: true,
top: false,
bottom: false
};
let fence_vert = Tile::Fence {
left: false,
right: false,
top: true,
bottom: true
};
let grass = Tile::Grass;
let block = [
[
path_crossing,
path_horiz,
path_horiz,
path_horiz,
path_horiz,
path_horiz,
@ -159,7 +217,31 @@ impl Chunk {
path_crossing
],
[
path_vert,
Tile::Fence {
left: false,
right: true,
top: false,
bottom: true
},
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
Tile::Fence {
left: true,
right: false,
top: false,
bottom: true
},
path_vert
],
[
fence_vert,
grass,
grass,
grass,
@ -169,10 +251,11 @@ impl Chunk {
grass,
grass,
grass,
fence_vert,
path_vert
],
[
path_vert,
fence_vert,
grass,
grass,
house(ASSETS.overworld.house_roof_mid_left),
@ -182,10 +265,11 @@ impl Chunk {
grass,
grass,
grass,
fence_vert,
path_vert
],
[
path_vert,
fence_vert,
grass,
house(ASSETS.overworld.house_roof_left),
house(ASSETS.overworld.house_mid_window),
@ -195,10 +279,11 @@ impl Chunk {
grass,
grass,
grass,
fence_vert,
path_vert
],
[
path_vert,
fence_vert,
grass,
house(ASSETS.overworld.house_bottom_left),
house(ASSETS.overworld.house_bottom_door),
@ -208,27 +293,63 @@ impl Chunk {
grass,
grass,
grass,
fence_vert,
path_vert
],
[
path_vert,
fence_vert,
grass,
grass,
path(false, true, true, false),
Tile::Path {
left: false,
right: true,
top: true,
bottom: false
},
path_horiz,
path_horiz,
path_horiz,
path_horiz,
path_horiz,
path_horiz,
path(true, false, true, true)
fence_vert,
Tile::Path {
left: true,
right: false,
top: true,
bottom: true
}
],
[
path_vert, grass, grass, grass, grass, grass, grass, grass, grass, grass,
path_vert
fence_vert, grass, grass, grass, grass, grass, grass, grass, grass,
grass, fence_vert, path_vert
],
[
path_vert, grass, grass, grass, grass, grass, grass, grass, grass, grass,
fence_vert, grass, grass, grass, grass, grass, grass, grass, grass,
grass, fence_vert, path_vert
],
[
Tile::Fence {
left: false,
right: true,
top: true,
bottom: false
},
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
Tile::Fence {
left: true,
right: false,
top: true,
bottom: false
},
path_vert
]
];