From 77f388dd7526e6a21a247b01265e6d7ea2fb7cd4 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 16 Jan 2023 20:15:48 +0100 Subject: [PATCH] init world --- src/game.rs | 6 +++++- src/game/world.rs | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/game.rs b/src/game.rs index e6c7863..b265f59 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,7 +1,7 @@ use glium::{Surface, uniform}; use glium::uniforms::{Sampler, MinifySamplerFilter, MagnifySamplerFilter}; use glium::glutin::{ - event::{Event, WindowEvent, DeviceEvent, KeyboardInput, VirtualKeyCode}, + event::{Event, WindowEvent, DeviceEvent}, event_loop::{EventLoop, ControlFlow}, }; use std::time::Instant; @@ -21,15 +21,19 @@ use display::init_display; use shaders::{Programs, chunk::Vertex as ChunkVertex}; use camera::Camera; use controller::Controls; +use world::World; + struct State { pub camera: Camera, pub controls: Controls, + pub world: World } impl State { pub fn init() -> Self { Self { camera: Camera::default(), controls: Controls::default(), + world: World::new(), } } } diff --git a/src/game/world.rs b/src/game/world.rs index c905440..39405ab 100644 --- a/src/game/world.rs +++ b/src/game/world.rs @@ -11,6 +11,11 @@ pub struct World { pub chunks: HashMap } impl World { + pub fn new() -> Self { + Self { + chunks: HashMap::new() + } + } pub fn update_loaded_chunks(&mut self, around_position: Vec2, game_opt: &GameOptions) { let render_dist = game_opt.render_distance as i32; let inside_chunk = (around_position / CHUNK_SIZE as f32).as_ivec2();