Add fence to static worldgen #4

Merged
msrd0 merged 3 commits from fence-assets into main 2024-07-06 21:19:25 +00:00
7 changed files with 242 additions and 23 deletions

View file

@ -0,0 +1,21 @@
<svg version="1.1" width="512" height="512" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
stroke="black" stroke-width="1" fill="none">
<image x="0" y="0" width="64" height="64" href="grass.svg"/>
<!-- continuous upper line of the fence -->
<path d="M0,26 v4 h32 v-4 z" stroke="none" fill="saddlebrown"/>
<path d="M0,26 h32 m-32,4 h32"/>
<!-- continuous lower line of the fence -->
<path d="M0,34 v4 h32 v-4 z" stroke="none" fill="saddlebrown"/>
<path d="M0,34 h32 m-32,4 h32"/>
<!-- continuous upper line of the fence, vertical this time -->
<path d="M30,32 h4 v32 h-4 z" stroke="none" fill="saddlebrown"/>
<path d="M30,32 v32 M34,32 v32"/>
<!-- fence post -->
<path d="M28,40 v-16 l4,-4 l4,4 v16 z" fill="saddlebrown"/>
</svg>

After

Width:  |  Height:  |  Size: 757 B

View file

@ -0,0 +1,9 @@
<svg version="1.1" width="512" height="512" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
stroke="black" stroke-width="1" fill="none">
<image x="0" y="0" width="64" height="64" href="grass.svg"/>
<image x="0" y="0" width="64" height="64" href="fence-bottom-left.svg"
transform="translate(32,0) scale(-1,1) translate(-32,0)"/>
</svg>

After

Width:  |  Height:  |  Size: 351 B

View file

@ -0,0 +1,20 @@
<svg version="1.1" width="512" height="512" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
stroke="black" stroke-width="1" fill="none">
<image x="0" y="0" width="64" height="64" href="grass.svg"/>
<!-- continuous upper line of the fence -->
<path d="M0,26 v4 h64 v-4 z" stroke="none" fill="saddlebrown"/>
<path d="M0,26 h64 m-64,4 h64"/>
<!-- continuous lower line of the fence -->
<path d="M0,34 v4 h64 v-4 z" stroke="none" fill="saddlebrown"/>
<path d="M0,34 h64 m-64,4 h64"/>
<!-- left fence post -->
<path d="M12,40 v-16 l4,-4 l4,4 v16 z" fill="saddlebrown"/>
<!-- right fence post -->
<path d="M44,40 v-16 l4,-4 l4,4 v16 z" fill="saddlebrown"/>
</svg>

After

Width:  |  Height:  |  Size: 684 B

View file

@ -0,0 +1,21 @@
<svg version="1.1" width="512" height="512" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
stroke="black" stroke-width="1" fill="none">
<image x="0" y="0" width="64" height="64" href="grass.svg"/>
<!-- continuous upper line of the fence -->
<path d="M0,26 v4 h32 v-4 z" stroke="none" fill="saddlebrown"/>
<path d="M0,26 h32 m-32,4 h32"/>
<!-- continuous lower line of the fence -->
<path d="M0,34 v4 h32 v-4 z" stroke="none" fill="saddlebrown"/>
<path d="M0,34 h32 m-32,4 h32"/>
<!-- continuous upper line of the fence, vertical this time -->
<path d="M30,0 h4 v32 h-4 z" stroke="none" fill="saddlebrown"/>
<path d="M30,0 v32 M34,0 v32"/>
<!-- fence post -->
<path d="M28,40 v-16 l4,-4 l4,4 v16 z" fill="saddlebrown"/>
</svg>

After

Width:  |  Height:  |  Size: 754 B

View file

@ -0,0 +1,9 @@
<svg version="1.1" width="512" height="512" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
stroke="black" stroke-width="1" fill="none">
<image x="0" y="0" width="64" height="64" href="grass.svg"/>
<image x="0" y="0" width="64" height="64" href="fence-top-left.svg"
transform="translate(32,0) scale(-1,1) translate(-32,0)"/>
</svg>

After

Width:  |  Height:  |  Size: 348 B

View file

@ -0,0 +1,18 @@
<svg version="1.1" width="512" height="512" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
stroke="black" stroke-width="1" fill="none">
<image x="0" y="0" width="64" height="64" href="grass.svg"/>
<!-- continuous upper line of the fence -->
<path d="M30,0 h4 v64 h-4 z" stroke="none" fill="saddlebrown"/>
<path d="M30,0 v64 M34,0 v64"/>
<!-- upper fence post -->
<path d="M28,24 h8 v-12 l-4,-4 l-4,4 z" stroke="none" fill="saddlebrown"/>
<path d="M30,16 v8 h-2 v-12 l4,-4 l4,4 v12 h-2 v-8 z"/>
<!-- lower fence post -->
<path d="M28,56 h8 v-12 l-4,-4 l-4,4 z" stroke="none" fill="saddlebrown"/>
<path d="M30,48 v8 h-2 v-12 l4,-4 l4,4 v12 h-2 v-8 z"/>
</svg>

After

Width:  |  Height:  |  Size: 683 B

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
]
];