From 1e77601579065df48a9b1d9daa9dba46522842ca Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Mon, 23 Oct 2017 11:57:59 -0500 Subject: -decent starting point, but centering does not seem to be working --- src/main.rs | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..81583b8 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,61 @@ +extern crate pancurses; +use pancurses::{initscr, endwin, noecho, start_color, Input, init_pair, COLOR_YELLOW, COLOR_BLACK, COLOR_WHITE, COLOR_BLUE, COLOR_GREEN, cbreak, curs_set}; + +mod map; +mod view; +mod list; +mod character; +mod location; + +use map::Map; +use view::View; +use list::List; +use character::Character; +use location::Location; + +fn init() -> pancurses::Window { + let main = initscr(); + main.clear(); + noecho(); + cbreak(); + curs_set(0); + main.timeout(100); + start_color(); + init_pair(1, COLOR_GREEN, COLOR_BLACK); + init_pair(2, COLOR_YELLOW, COLOR_BLACK); + init_pair(3, COLOR_WHITE, COLOR_WHITE); + init_pair(4, COLOR_WHITE, COLOR_BLUE); + main +} + +fn main() { + + let main = init(); + + let mut map = Map::new(); + let mut view = View::new(main.get_max_yx(), &map.window); + let cursor = Character::new('X', 3, Location{x:150,y:150}); + + map.fill(); + let list = List::new(map.impassable.to_vec()); + list.draw(&map.window); + cursor.draw(&map.window); + + let paused = false; + loop{ + match main.getch() { + Some(Input::Character(c)) => break, + _ => () + } + + if !paused { + list.action(); + } + map.fill(); + list.draw(&map.window); + cursor.draw(&map.window); + view.center(cursor, map.window.get_max_yx()); + } + + endwin(); +} -- cgit v1.2.3