mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 12:25:02 +01:00
Add some world defs
This commit is contained in:
parent
608f8f9f9f
commit
d78726eb5b
6 changed files with 61 additions and 0 deletions
28
src/world.rs
Normal file
28
src/world.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use fnv::FnvHashMap;
|
||||
|
||||
type ChunkPosScalar = i16;
|
||||
|
||||
#[derive(Hash)]
|
||||
struct ChunkPos {
|
||||
x: ChunkPosScalar,
|
||||
y: ChunkPosScalar,
|
||||
}
|
||||
|
||||
pub struct World {
|
||||
chunks: FnvHashMap<ChunkPos, Chunk>,
|
||||
}
|
||||
|
||||
const CHUNK_EXTENT: u16 = 256;
|
||||
const CHUNK_N_BLOCKS: usize = CHUNK_EXTENT as usize * CHUNK_EXTENT as usize;
|
||||
|
||||
type ChunkBlocks = [Block; CHUNK_N_BLOCKS];
|
||||
|
||||
pub struct Chunk {
|
||||
blocks: ChunkBlocks,
|
||||
}
|
||||
|
||||
type BlockId = u16;
|
||||
|
||||
pub struct Block {
|
||||
id: BlockId,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue