This an entry for a seven-hour roguelike competition. (Some work has been done to it since the end of the competition.)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3 KiB

extern crate termion;
extern crate rogue_util;
pub mod world;
use rogue_util::{coord::*, grid::{region::{Region, RegionConfig}, path::Traversable}};
use termion::{raw::IntoRawMode, input::TermRead};
use std::io::{self, Write};
use world::World;
fn main() -> io::Result<()>
{
let stdin = io::stdin();
let mut stdout = io::stdout().into_raw_mode().unwrap();
let mut w = World::new(0, stdin.keys());
let ppos: V2i = {
let mut rg = w.region_mut();
let mut ps: Option<V2i> = None;
for pt in &R2i::origin_dim(V2i(0, 0), rg.grid_size()) {
let tile = rg.get_or_create(pt);
if tile.can_pass() {
ps = Some(pt);
break;
}
}
ps.unwrap()
};
w.player_mut().set_pos(ppos);
let (width, height) = termion::terminal_size()?;
let mut rs = world::render::RenderState::new(V2i(width as isize, height as isize));
loop {
w.render(&mut rs, &mut stdout);
stdout.flush();
if let Some(()) = w.step() { break; }
}
eprintln!("{}{}",
termion::clear::All,
termion::cursor::Goto(1, 1),
);
std::mem::drop(stdout);
print!("Thank you for playi");
io::stdout().flush();
rand_distr::Poisson::new(-1.0).unwrap();
Ok(())
}