diff --git a/assets/arrow.png b/assets/arrow.png new file mode 100644 index 0000000..08ad5c1 Binary files /dev/null and b/assets/arrow.png differ diff --git a/src/game/chunk.rs b/src/game/chunk.rs index c33ceac..0997b1e 100644 --- a/src/game/chunk.rs +++ b/src/game/chunk.rs @@ -1,9 +1,7 @@ use std::collections::HashMap; -use gl_matrix::{common::*, vec2::clone}; -use png::chunk; -use crate::{systems::WorldGenerator, tools::Sides}; +use crate::tools::Sides; use super::{block::Block, WPos}; diff --git a/src/game/world.rs b/src/game/world.rs index e612acc..4f7c3e5 100644 --- a/src/game/world.rs +++ b/src/game/world.rs @@ -1,7 +1,5 @@ use std::collections::HashMap; -use png::chunk; - use crate::{graphics::Draw, systems::WorldGenerator}; use super::{block::Block, chunk::Chunk, BlockType, Sides, WPos}; @@ -30,7 +28,7 @@ impl World { updates: vec![], i_updates: vec![], t_updates: vec![], - gen: Box::new(|world: &mut World, chunk_x: i32, chunk_z: i32| {}), + gen: Box::new(|_world: &mut World, _chunk_x: i32, _chunk_z: i32| {}), } } diff --git a/src/jucraft.rs b/src/jucraft.rs index f06db3b..31273b8 100644 --- a/src/jucraft.rs +++ b/src/jucraft.rs @@ -114,9 +114,10 @@ pub fn register(ctx: &mut Context, game: &mut Game, graphics: &mut Graphics, def world.set_gen(Box::new(|world: &mut World, chunk_x: i32, chunk_z: i32| { for x in chunk_x * 16..chunk_x * 16 + 16 { for z in chunk_z * 16..chunk_z * 16 + 16 { - for y in 0..64 { + for y in 0..63 { world.set_block_tex(&[x, y, z], 1, Sides::all(false), false, false); } + world.set_block_tex(&[x, 63, z], 4, Sides::all(false), false, false); } } })); diff --git a/src/jucraft/default_solid_block.rs b/src/jucraft/default_solid_block.rs index c1ecca9..94bcd85 100644 --- a/src/jucraft/default_solid_block.rs +++ b/src/jucraft/default_solid_block.rs @@ -80,7 +80,7 @@ impl BlockType for DefaultSolidBlock { fn collision(&self, _world: &World, _block: WPos) -> Vec<(Vec3, Vec3)> { vec![([0.,0.,0.], [1.,1.,1.])] } - fn interaction(&self, _world: &World, block: &Block, _block: WPos) -> Vec<(Vec3, Vec3)> { + fn interaction(&self, _world: &World, _block: &Block, _pos: WPos) -> Vec<(Vec3, Vec3)> { vec![([0.,0.,0.], [1.,1.,1.])] } } diff --git a/src/main.rs b/src/main.rs index 8b22a97..828f9ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use miniquad::*; use stage::Stage; mod game; -mod shader; +mod render_helper; mod stage; mod graphics; mod tools; diff --git a/src/shader.rs b/src/render_helper.rs similarity index 99% rename from src/shader.rs rename to src/render_helper.rs index 6374846..a2d60c7 100644 --- a/src/shader.rs +++ b/src/render_helper.rs @@ -1,6 +1,6 @@ use std::f64::consts::PI; -use gl_matrix::{common::*, *}; +use gl_matrix::*; use miniquad::*; pub mod post; diff --git a/src/shader/post.rs b/src/render_helper/post.rs similarity index 100% rename from src/shader/post.rs rename to src/render_helper/post.rs diff --git a/src/stage.rs b/src/stage.rs index ae88327..d423913 100644 --- a/src/stage.rs +++ b/src/stage.rs @@ -2,7 +2,7 @@ use gl_matrix::{mat4, common::*}; use miniquad::*; -use crate::{game::{Game, chunk::*, world::World}, graphics::{Graphics, DrawType}, jucraft::{*, self}, shader::RenderHelper, tools::*, player::Player}; +use crate::{game::{Game, chunk::*, world::World}, graphics::{Graphics, DrawType}, jucraft::{*, self}, render_helper::RenderHelper, tools::*, player::Player}; const MAX_INSTANT_TICKS: i32 = 50; @@ -102,8 +102,7 @@ impl Stage { 11, 10, 9, 0, 1, 2, // back - 3, 2, 1, - + 3, 2, 1, ]; let index_buffer = Buffer::immutable(ctx, BufferType::IndexBuffer, &indices); @@ -126,11 +125,11 @@ impl Stage { &[BufferLayout::default(), BufferLayout { step_func: VertexStep::PerInstance, ..Default::default() - },], + }], &[ VertexAttribute::with_buffer("pos", VertexFormat::Float3,0), VertexAttribute::with_buffer("uv", VertexFormat::Float2,0), - VertexAttribute::with_buffer("wpos", VertexFormat::Int3, 1), + VertexAttribute::with_buffer("wpos", VertexFormat::Int3, 1), ], shader, PipelineParams { diff --git a/src/systems.rs b/src/systems.rs index 4d9de5b..414d050 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -1,6 +1,6 @@ use gl_matrix::common::*; -use crate::{game::{world::World, block::Block}, tools::WPos, graphics::{Draw, DrawType}}; +use crate::{game::{world::World, block::Block, Game}, tools::WPos, graphics::{Draw, DrawType}}; @@ -20,6 +20,6 @@ pub trait BlockType { fn update(&self, _world: &mut World, _block: WPos, _types: &Vec>, _instant: bool) {} fn render(&self, _world: &mut World, _block: WPos) -> Draw { Draw::None() } fn collision(&self, _world: &World, _block: WPos) -> Vec<(Vec3, Vec3)> { vec![] } - fn interaction(&self, _world: &World, block: &Block, _block: WPos) -> Vec<(Vec3, Vec3)> { vec![] } + fn interaction(&self, _world: &World, _block: &Block, _pos: WPos) -> Vec<(Vec3, Vec3)> { vec![] } fn texture(&self) -> &DrawType; } \ No newline at end of file diff --git a/src/tools.rs b/src/tools.rs index efb0591..2aa76ef 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -80,12 +80,12 @@ pub fn block_collision( direction: Vec3, size2: Vec3, ) -> Option<(f32, Side)> { - let mut d_x = (pos2[0] - pos1[0]) / direction[0]; - let mut d_y = (pos2[1] - pos1[1]) / direction[1]; - let mut d_z = (pos2[2] - pos1[2]) / direction[2]; - let mut d_b_x = (pos2[0] + size2[0] - pos1[0]) / direction[0]; - let mut d_b_y = (pos2[1] + size2[1] - pos1[1]) / direction[1]; - let mut d_b_z = (pos2[2] + size2[2] - pos1[2]) / direction[2]; + let d_x = (pos2[0] - pos1[0]) / direction[0]; + let d_y = (pos2[1] - pos1[1]) / direction[1]; + let d_z = (pos2[2] - pos1[2]) / direction[2]; + let d_b_x = (pos2[0] + size2[0] - pos1[0]) / direction[0]; + let d_b_y = (pos2[1] + size2[1] - pos1[1]) / direction[1]; + let d_b_z = (pos2[2] + size2[2] - pos1[2]) / direction[2]; let mut out: Option<(f32, Side)> = None; let mut dist = INFINITY;