mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 20:35:02 +01:00
Add tile graphic
This commit is contained in:
parent
d78726eb5b
commit
fbc7e35f9e
11 changed files with 812 additions and 20 deletions
21
src/world.rs
21
src/world.rs
|
|
@ -1,4 +1,5 @@
|
|||
use fnv::FnvHashMap;
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
type ChunkPosScalar = i16;
|
||||
|
||||
|
|
@ -12,6 +13,14 @@ pub struct World {
|
|||
chunks: FnvHashMap<ChunkPos, Chunk>,
|
||||
}
|
||||
|
||||
impl Default for World {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
chunks: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CHUNK_EXTENT: u16 = 256;
|
||||
const CHUNK_N_BLOCKS: usize = CHUNK_EXTENT as usize * CHUNK_EXTENT as usize;
|
||||
|
||||
|
|
@ -21,8 +30,20 @@ pub struct Chunk {
|
|||
blocks: ChunkBlocks,
|
||||
}
|
||||
|
||||
impl Chunk {
|
||||
pub fn new_rand() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let mut blocks = [Block { id: 0 }; CHUNK_N_BLOCKS];
|
||||
for b in &mut blocks {
|
||||
b.id = rng.gen();
|
||||
}
|
||||
Self { blocks }
|
||||
}
|
||||
}
|
||||
|
||||
type BlockId = u16;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Block {
|
||||
id: BlockId,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue