mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
init world
This commit is contained in:
parent
2a647604ff
commit
77f388dd75
|
@ -1,7 +1,7 @@
|
||||||
use glium::{Surface, uniform};
|
use glium::{Surface, uniform};
|
||||||
use glium::uniforms::{Sampler, MinifySamplerFilter, MagnifySamplerFilter};
|
use glium::uniforms::{Sampler, MinifySamplerFilter, MagnifySamplerFilter};
|
||||||
use glium::glutin::{
|
use glium::glutin::{
|
||||||
event::{Event, WindowEvent, DeviceEvent, KeyboardInput, VirtualKeyCode},
|
event::{Event, WindowEvent, DeviceEvent},
|
||||||
event_loop::{EventLoop, ControlFlow},
|
event_loop::{EventLoop, ControlFlow},
|
||||||
};
|
};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
@ -21,15 +21,19 @@ use display::init_display;
|
||||||
use shaders::{Programs, chunk::Vertex as ChunkVertex};
|
use shaders::{Programs, chunk::Vertex as ChunkVertex};
|
||||||
use camera::Camera;
|
use camera::Camera;
|
||||||
use controller::Controls;
|
use controller::Controls;
|
||||||
|
use world::World;
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
pub camera: Camera,
|
pub camera: Camera,
|
||||||
pub controls: Controls,
|
pub controls: Controls,
|
||||||
|
pub world: World
|
||||||
}
|
}
|
||||||
impl State {
|
impl State {
|
||||||
pub fn init() -> Self {
|
pub fn init() -> Self {
|
||||||
Self {
|
Self {
|
||||||
camera: Camera::default(),
|
camera: Camera::default(),
|
||||||
controls: Controls::default(),
|
controls: Controls::default(),
|
||||||
|
world: World::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,11 @@ pub struct World {
|
||||||
pub chunks: HashMap<IVec2, Chunk>
|
pub chunks: HashMap<IVec2, Chunk>
|
||||||
}
|
}
|
||||||
impl World {
|
impl World {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
chunks: HashMap::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn update_loaded_chunks(&mut self, around_position: Vec2, game_opt: &GameOptions) {
|
pub fn update_loaded_chunks(&mut self, around_position: Vec2, game_opt: &GameOptions) {
|
||||||
let render_dist = game_opt.render_distance as i32;
|
let render_dist = game_opt.render_distance as i32;
|
||||||
let inside_chunk = (around_position / CHUNK_SIZE as f32).as_ivec2();
|
let inside_chunk = (around_position / CHUNK_SIZE as f32).as_ivec2();
|
||||||
|
|
Loading…
Reference in a new issue