From 25238acd9b2140505df84f3bc329b6ba3ca4bc4e Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 16 Jan 2023 17:22:19 +0100 Subject: [PATCH] wip --- src/game.rs | 2 +- src/game/chunk.rs | 6 ------ src/game/options.rs | 3 +++ src/game/world.rs | 9 ++++++++- src/game/world/chunk.rs | 23 +++++++++++++++++++++++ 5 files changed, 35 insertions(+), 8 deletions(-) delete mode 100644 src/game/chunk.rs create mode 100644 src/game/options.rs create mode 100644 src/game/world/chunk.rs diff --git a/src/game.rs b/src/game.rs index 71aeb1d..e6c7863 100644 --- a/src/game.rs +++ b/src/game.rs @@ -12,9 +12,9 @@ mod shaders; mod camera; mod controller; mod world; -mod chunk; mod blocks; mod items; +mod options; use assets::Assets; use display::init_display; diff --git a/src/game/chunk.rs b/src/game/chunk.rs deleted file mode 100644 index fdd49ea..0000000 --- a/src/game/chunk.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub const CHUNK_SIZE: u8 = 16; -pub const CHUNK_HEIGHT: u8 = 255; - -pub struct Chunk { - -} diff --git a/src/game/options.rs b/src/game/options.rs new file mode 100644 index 0000000..27f54bf --- /dev/null +++ b/src/game/options.rs @@ -0,0 +1,3 @@ +pub struct GameOptions { + pub render_distance: u8, +} diff --git a/src/game/world.rs b/src/game/world.rs index ab3ce3b..4ce8f1f 100644 --- a/src/game/world.rs +++ b/src/game/world.rs @@ -1,6 +1,13 @@ use std::collections::HashMap; -use crate::game::chunk::Chunk; + +mod chunk; +use chunk::Chunk; pub struct World { chunks: HashMap<(i32, i32), Chunk> } +impl World { + // pub fn update_loaded_chunks(around: ) { + + // } +} diff --git a/src/game/world/chunk.rs b/src/game/world/chunk.rs new file mode 100644 index 0000000..0ca150e --- /dev/null +++ b/src/game/world/chunk.rs @@ -0,0 +1,23 @@ +use glium::VertexBuffer; +use crate::game::{ + blocks::Block, + shaders::chunk::Vertex as ChunkVertex +}; + +pub const CHUNK_SIZE: usize = 16; +pub const CHUNK_HEIGHT: usize = 255; + +pub enum ChunkState { + //AwaitsLoading, + //Loaded, + //AwaitsMesh, + //Rendered, + //AwaitsUnload +} + +pub struct Chunk { + pub coords: (i32, i32), + pub block_data: Option<[[[Block; CHUNK_SIZE]; CHUNK_HEIGHT]; CHUNK_SIZE]>, + pub vertex_buffer: Option>, + pub state: ChunkState +}