mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 20:08:20 -06:00
init world
This commit is contained in:
parent
2a647604ff
commit
77f388dd75
|
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,11 @@ pub struct World {
|
|||
pub chunks: HashMap<IVec2, Chunk>
|
||||
}
|
||||
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();
|
||||
|
|
Loading…
Reference in a new issue