|
|
|
@ -4,7 +4,6 @@ extern crate termion;
|
|
|
|
|
|
|
|
|
|
use crate::noise::utils::NoiseMapBuilder; |
|
|
|
|
use crate::termion::cursor::DetectCursorPos; |
|
|
|
|
use noise::utils::NoiseMap; |
|
|
|
|
use noise::utils::PlaneMapBuilder; |
|
|
|
|
use noise::Fbm; |
|
|
|
|
use std::fmt::Debug; |
|
|
|
@ -32,8 +31,8 @@ pub struct Player {
|
|
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] |
|
|
|
|
pub struct Pos { |
|
|
|
|
pub x: u16, |
|
|
|
|
pub y: u16, |
|
|
|
|
pub x: usize, |
|
|
|
|
pub y: usize, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl GOL { |
|
|
|
@ -62,7 +61,10 @@ impl GOL {
|
|
|
|
|
let mut s = Self { |
|
|
|
|
screen: Box::new(screen), |
|
|
|
|
player: Player { |
|
|
|
|
pos: Pos { x: 0, y: 0 }, |
|
|
|
|
pos: Pos { |
|
|
|
|
x: MAP_SIZE_X / 2, |
|
|
|
|
y: MAP_SIZE_Y / 2, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
map: map, |
|
|
|
|
}; |
|
|
|
@ -146,8 +148,10 @@ fn draw(game: &mut GOL) {
|
|
|
|
|
game.write(&'X'); |
|
|
|
|
for col in 1..size.0 { |
|
|
|
|
for row in 1..size.1 { |
|
|
|
|
if let Some(r) = game.map.clone().get_mut((row + game.player.pos.x) as usize) { |
|
|
|
|
if let Some(cell) = r.get_mut((col + game.player.pos.y) as usize) { |
|
|
|
|
let cell_x = game.player.pos.x + row as usize; |
|
|
|
|
let cell_y = game.player.pos.y + col as usize; |
|
|
|
|
if let Some(r) = game.map.clone().get_mut(cell_x) { |
|
|
|
|
if let Some(cell) = r.get_mut(cell_y) { |
|
|
|
|
game.write(&cursor::Goto(row, col)); |
|
|
|
|
game.write(&cell); |
|
|
|
|
} |
|
|
|
|