This commit is contained in:
griffi-gh 2023-01-16 17:22:19 +01:00
parent ef9e24722a
commit 25238acd9b
5 changed files with 35 additions and 8 deletions

View file

@ -12,9 +12,9 @@ mod shaders;
mod camera; mod camera;
mod controller; mod controller;
mod world; mod world;
mod chunk;
mod blocks; mod blocks;
mod items; mod items;
mod options;
use assets::Assets; use assets::Assets;
use display::init_display; use display::init_display;

View file

@ -1,6 +0,0 @@
pub const CHUNK_SIZE: u8 = 16;
pub const CHUNK_HEIGHT: u8 = 255;
pub struct Chunk {
}

3
src/game/options.rs Normal file
View file

@ -0,0 +1,3 @@
pub struct GameOptions {
pub render_distance: u8,
}

View file

@ -1,6 +1,13 @@
use std::collections::HashMap; use std::collections::HashMap;
use crate::game::chunk::Chunk;
mod chunk;
use chunk::Chunk;
pub struct World { pub struct World {
chunks: HashMap<(i32, i32), Chunk> chunks: HashMap<(i32, i32), Chunk>
} }
impl World {
// pub fn update_loaded_chunks(around: ) {
// }
}

23
src/game/world/chunk.rs Normal file
View file

@ -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<VertexBuffer<ChunkVertex>>,
pub state: ChunkState
}