|
|
|
@ -14,7 +14,7 @@ use std::collections::HashMap;
|
|
|
|
|
// Just like example 3, but we're adding an additional vector: visible
|
|
|
|
|
struct State { |
|
|
|
|
view: Chunk, |
|
|
|
|
loaded_chunks: HashMap<(i32, i32), Chunk>, |
|
|
|
|
loaded_chunks: Box<HashMap<(i32, i32), Chunk>>, |
|
|
|
|
world_pos: (i32, i32), |
|
|
|
|
player_position: usize, |
|
|
|
|
visible: Vec<bool>, |
|
|
|
@ -46,7 +46,7 @@ impl State {
|
|
|
|
|
let state = State { |
|
|
|
|
world_pos: (0, 0), |
|
|
|
|
view: chunks.get(&(0, 0)).unwrap().to_vec(), |
|
|
|
|
loaded_chunks: chunks, |
|
|
|
|
loaded_chunks: Box::new(chunks), |
|
|
|
|
player_position: (25 * 80) + 40, // Equivalent to point2d_to_index(40, 25) but we haven't initialized it yet
|
|
|
|
|
visible: vec![false; 80 * 50], |
|
|
|
|
}; |
|
|
|
@ -215,7 +215,7 @@ impl Algorithm2D for State {
|
|
|
|
|
|
|
|
|
|
fn main() -> RltkError { |
|
|
|
|
let context = RltkBuilder::simple80x50() |
|
|
|
|
.with_title("RLTK Example 4 - Field-Of-View") |
|
|
|
|
.with_title("Tales of Midgard") |
|
|
|
|
.build()?; |
|
|
|
|
let gs = State::new(); |
|
|
|
|
rltk::main_loop(context, gs) |
|
|
|
|