From c2c9a2e507f25fcd581aec189ad196f6c61ab069 Mon Sep 17 00:00:00 2001 From: jusax23 Date: Thu, 20 Apr 2023 13:09:31 +0200 Subject: [PATCH] grass_world --- assets/arrow.png | Bin 0 -> 735 bytes src/game/chunk.rs | 4 +--- src/game/world.rs | 4 +--- src/jucraft.rs | 3 ++- src/jucraft/default_solid_block.rs | 2 +- src/main.rs | 2 +- src/{shader.rs => render_helper.rs} | 2 +- src/{shader => render_helper}/post.rs | 0 src/stage.rs | 9 ++++----- src/systems.rs | 4 ++-- src/tools.rs | 12 ++++++------ 11 files changed, 19 insertions(+), 23 deletions(-) create mode 100644 assets/arrow.png rename src/{shader.rs => render_helper.rs} (99%) rename src/{shader => render_helper}/post.rs (100%) diff --git a/assets/arrow.png b/assets/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..08ad5c19836cc8d8c8ed136d61ffca3787672ace GIT binary patch literal 735 zcmV<50wDc~P)EX>4Tx04R}tkv&MmKpe$iKcpfR!DbL~$WWauh>AFB6^c+H)C#RSm|Xe=O$fqw6tAnc`2!4RLx;QDiNQwVT3N2zhIPS;0dyl(!K(J9|niU=cG~G5c zsic_8uZWRXgb_nO1jJ-!8MBg)|5Tqat9cAGGtSBr4Y?vu?W1M(KqFR*e%er>h;#z$LRx*rLNL9z`-Ff zQljiNpLch6_V(|YR)0S^#&VD~h+2sN000SaNLh0L04^f{04^f|c%?sf00007bV*G` z2j>J65*HkPnQ-g?000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0002W zNklhhhB9d2eJ%|W1LFIVh!4^mSdWwbojQ2oYV^N+Z*Vzu)@cka*?U+P1xkD}{#h zJa3}#Ge0T6IOnP&CHlUvilnuUqU*Y 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;