diff --git a/assets/blocks.png b/assets/blocks.png index da6442d..1323f05 100644 Binary files a/assets/blocks.png and b/assets/blocks.png differ diff --git a/src/block_reg.rs b/src/block_reg.rs index 0142fc7..10e0f6f 100644 --- a/src/block_reg.rs +++ b/src/block_reg.rs @@ -14,6 +14,7 @@ pub const WOOD: Block = 6; pub const LEAVES: Block = 7; pub const GLASS: Block = 8; pub const GLOWSTONE: Block = 9; +pub const WATER: Block = 10; pub const VOXEL_DIMS: [f32; 3] = [1.0, 1.0, 1.0]; @@ -31,11 +32,28 @@ pub struct BlockRegistry { leaves_block: Mesh, glass_block: Mesh, glowstone_block: Mesh, + water_block: Mesh, } impl Default for BlockRegistry { fn default() -> Self { BlockRegistry { + water_block: generate_voxel_mesh( + VOXEL_DIMS, + ATLAS_CORDS, + [ + (Top, [11, 0]), + (Bottom, [11, 0]), + (Right, [11, 0]), + (Left, [11, 0]), + (Forward, [11, 0]), + (Back, [11, 0]), + ], + PADDING, + Some(0.75), + 0.8, + ), + grass_block: generate_voxel_mesh( VOXEL_DIMS, ATLAS_CORDS, @@ -49,6 +67,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), dirt_block: generate_voxel_mesh( VOXEL_DIMS, @@ -63,6 +82,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), stone_block: generate_voxel_mesh( VOXEL_DIMS, @@ -77,6 +97,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), bricks_block: generate_voxel_mesh( VOXEL_DIMS, @@ -91,6 +112,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), log_block: generate_voxel_mesh( VOXEL_DIMS, @@ -105,6 +127,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.90), + 1.0, ), wood_block: generate_voxel_mesh( VOXEL_DIMS, @@ -119,6 +142,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), leaves_block: generate_voxel_mesh( VOXEL_DIMS, @@ -133,6 +157,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), glass_block: generate_voxel_mesh( VOXEL_DIMS, @@ -147,6 +172,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), glowstone_block: generate_voxel_mesh( VOXEL_DIMS, @@ -161,6 +187,7 @@ impl Default for BlockRegistry { ], PADDING, Some(0.75), + 1.0, ), } } @@ -187,7 +214,7 @@ impl VoxelRegistry for BlockRegistry { } fn is_covering(&self, voxel: &Self::Voxel, _side: prelude::Face) -> bool { - *voxel != AIR && *voxel != LEAVES && *voxel != GLASS + *voxel != AIR && *voxel != LEAVES && *voxel != GLASS && *voxel != WATER } fn get_mesh(&self, voxel: &Self::Voxel) -> VoxelMesh<&Mesh> { @@ -202,6 +229,7 @@ impl VoxelRegistry for BlockRegistry { LEAVES => VoxelMesh::NormalCube(&self.leaves_block), GLASS => VoxelMesh::NormalCube(&self.glass_block), GLOWSTONE => VoxelMesh::NormalCube(&self.glowstone_block), + WATER => VoxelMesh::NormalCube(&self.water_block), _ => VoxelMesh::Null, } } diff --git a/src/inventory.rs b/src/inventory.rs index d84b2ae..6205872 100644 --- a/src/inventory.rs +++ b/src/inventory.rs @@ -13,7 +13,7 @@ impl Default for Inventory { Inventory { current: 0, items: vec![ - GRASS, DIRT, STONE, BRICKS, LOG, WOOD, LEAVES, GLASS, GLOWSTONE, + GRASS, DIRT, STONE, BRICKS, LOG, WOOD, LEAVES, GLASS, GLOWSTONE, WATER, ], } } @@ -39,35 +39,35 @@ fn input_inventory(mut inv: ResMut, keys: Res>) { inv.current = 2; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key3) { + if keys.just_pressed(KeyCode::Key3) || keys.just_pressed(KeyCode::R) { inv.current = 3; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key4) { + if keys.just_pressed(KeyCode::Key4) || keys.just_pressed(KeyCode::Z) { inv.current = 4; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key5) { + if keys.just_pressed(KeyCode::Key5) || keys.just_pressed(KeyCode::X) { inv.current = 5; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key6) { + if keys.just_pressed(KeyCode::Key6) || keys.just_pressed(KeyCode::C) { inv.current = 6; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key7) { + if keys.just_pressed(KeyCode::Key7) || keys.just_pressed(KeyCode::V) { inv.current = 7; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key8) { + if keys.just_pressed(KeyCode::Key8) || keys.just_pressed(KeyCode::G) { inv.current = 8; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key9) { + if keys.just_pressed(KeyCode::Key9) || keys.just_pressed(KeyCode::T) { inv.current = 9; inv.current = inv.current % inv.items.len(); } - if keys.just_pressed(KeyCode::Key0) { + if keys.just_pressed(KeyCode::Key0) || keys.just_pressed(KeyCode::F) { inv.current = 0; inv.current = inv.current % inv.items.len(); }