aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2019-11-18 05:38:59 +0000
committerGuillaume Pasquet <dev@etenil.net>2019-11-18 05:38:59 +0000
commit53928f4b6ceb607bca08cf9a2a36824b0944f2c1 (patch)
treecec20b5fa470826e362297c20f404813f1cf7d70
parent545a32a6830d722835ed3d739165f498b874b8d8 (diff)
Convert from ncurses to crossterm
-rw-r--r--Cargo.lock155
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs63
-rw-r--r--src/state.rs63
-rw-r--r--src/tiling.rs2
-rw-r--r--src/world.rs2
6 files changed, 182 insertions, 105 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 79ba554..2272f55 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6,22 +6,56 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "bitflags"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "c2-chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "cc"
-version = "1.0.37"
+name = "cfg-if"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "cfg-if"
-version = "0.1.9"
+name = "crossterm"
+version = "0.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "crossterm_winapi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
+ "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "crossterm_winapi"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "fuchsia-zircon"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "fuchsia-zircon-sys"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -29,13 +63,30 @@ name = "getrandom"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "iovec"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "kernel32-sys"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "lazy_static"
-version = "1.3.0"
+version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -55,42 +106,44 @@ dependencies = [
]
[[package]]
-name = "ncurses"
-version = "5.99.0"
+name = "mio"
+version = "0.6.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
- "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
+ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "pancurses"
-version = "0.16.1"
+name = "miow"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "ncurses 5.99.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "pdcurses-sys 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "pdcurses-sys"
-version = "0.7.1"
+name = "net2"
+version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "pkg-config"
-version = "0.3.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "ppv-lite86"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -137,12 +190,17 @@ dependencies = [
name = "roguelike"
version = "0.1.0"
dependencies = [
- "pancurses 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "crossterm 0.13.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"text_io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "slab"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "spin"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -154,7 +212,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
-version = "0.3.7"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "winapi"
+version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -162,6 +225,11 @@ dependencies = [
]
[[package]]
+name = "winapi-build"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -172,34 +240,43 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "winreg"
-version = "0.5.1"
+name = "ws2_32-sys"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf"
+"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101"
-"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d"
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
+"checksum crossterm 0.13.3 (registry+https://github.com/rust-lang/crates.io-index)" = "759f2256ab248ad498bdd62038187450921b1b8d24c348d198f3425b0bd289cb"
+"checksum crossterm_winapi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02de3a35bcabb5bb6dc7d4449abb546d23f123b06f074e2cf1c50db516da6ac8"
+"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
+"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55"
-"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
+"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
+"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
+"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
-"checksum ncurses 5.99.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15699bee2f37e9f8828c7b35b2bc70d13846db453f2d507713b758fabe536b82"
-"checksum pancurses 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d3058bc37c433096b2ac7afef1c5cdfae49ede0a4ffec3dfc1df1df0959d0ff0"
-"checksum pdcurses-sys 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "084dd22796ff60f1225d4eb6329f33afaf4c85419d51d440ab6b8c6f4529166b"
-"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
+"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23"
+"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
+"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b"
"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c"
"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d"
"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca"
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
+"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55"
"checksum text_io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9658b61ebd1d2a40c276ba2335890b9eb6550b67458a6fbce2022e58c3350a50"
-"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
+"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
+"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
+"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-"checksum winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a"
+"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
diff --git a/Cargo.toml b/Cargo.toml
index b26809f..e803045 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2018"
[dependencies]
rand = "0.7.0"
text_io = "0.1.7"
-pancurses = "0.16"
+crossterm = "0.13.3"
diff --git a/src/main.rs b/src/main.rs
index f890a27..8799a46 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,5 @@
-extern crate pancurses;
+extern crate crossterm;
extern crate rand;
-
extern crate text_io;
mod entities;
@@ -9,9 +8,14 @@ mod tiling;
mod world;
use entities::{Entity, Player};
-use pancurses::{endwin, initscr, noecho, Input};
use state::State;
use std::env;
+use std::io::{stdout, Write};
+use crossterm::{execute, Output};
+use crossterm::cursor;
+use crossterm::screen::{EnterAlternateScreen, LeaveAlternateScreen, RawScreen};
+use crossterm::input::{input, InputEvent, KeyEvent};
+use crossterm::terminal;
use world::{Dungeon, DOWN, LEFT, RIGHT, UP};
fn get_player_name() -> String {
@@ -22,53 +26,48 @@ fn get_player_name() -> String {
}
fn main() {
- let window = initscr();
+ let term_size = terminal::size().unwrap();
let mut state = State::new(
Player::new(get_player_name(), String::from("Warrior"), 30, 10, 10, 20),
Dungeon::new(
- window.get_max_x() as usize,
- (window.get_max_y() - 2) as usize,
+ term_size.0 as usize,
+ (term_size.1 - 2) as usize,
5,
),
);
state.init();
- window.keypad(true);
- noecho();
+ execute!(stdout(), EnterAlternateScreen).unwrap();
+ execute!(stdout(), cursor::Hide).unwrap();
+
+ let _raw = RawScreen::into_raw_mode();
- state.render_level(&window);
+ state.render_level();
+
+ let input = input();
+ let mut reader = input.read_sync();
loop {
// update
- state.render_entities(&window);
+ state.render_entities();
- state.render_player(&window);
+ state.render_player();
- // get input and execute it
- match window.getch() {
- Some(Input::Character('?')) => {
- window.addstr("q: quit\n");
- }
- Some(Input::Character('j')) => {
- state.player.move_by(DOWN).unwrap();
- // state.get_player_mut().move_by(DOWN).unwrap();
+ if let Some(event) = reader.next() {
+ match event {
+ InputEvent::Keyboard(KeyEvent::Char('q')) => break,
+ InputEvent::Keyboard(KeyEvent::Char('?')) => execute!(stdout(), Output("q: quit")).unwrap(),
+ InputEvent::Keyboard(KeyEvent::Char('j')) => state.player.move_by(DOWN).unwrap(),
+ InputEvent::Keyboard(KeyEvent::Char('k')) => state.player.move_by(UP).unwrap(),
+ InputEvent::Keyboard(KeyEvent::Char('h')) => state.player.move_by(LEFT).unwrap(),
+ InputEvent::Keyboard(KeyEvent::Char('l')) => state.player.move_by(RIGHT).unwrap(),
+ _ => ()
}
- Some(Input::Character('k')) => {
- state.get_player_mut().move_by(UP).unwrap();
- }
- Some(Input::Character('h')) => {
- state.get_player_mut().move_by(LEFT).unwrap();
- }
- Some(Input::Character('l')) => {
- state.get_player_mut().move_by(RIGHT).unwrap();
- }
- Some(Input::Character('q')) => break,
- Some(_) => (),
- None => (),
}
// actors actions (normally attack / interact if on same location as the character)
}
- endwin();
+
+ execute!(stdout(), LeaveAlternateScreen).unwrap();
}
diff --git a/src/state.rs b/src/state.rs
index b5ab6ca..038f46f 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -1,7 +1,9 @@
-use pancurses::Window;
+use std::io::{stdout, Write};
+use crossterm::{queue, Output};
+use crossterm::cursor::{MoveTo};
use crate::entities::{Character, Entity};
-use crate::tiling::{tile_to_str, TileGrid, TileType};
+use crate::tiling::{tile_to_str, TileGrid};
use crate::world::{Dungeon, Generatable, Level};
pub struct State {
@@ -11,10 +13,6 @@ pub struct State {
grid: Option<TileGrid>,
}
-pub fn draw_block(window: &Window, block: &TileType) {
- window.printw(tile_to_str(block));
-}
-
impl State {
pub fn new(player: Character, dungeon: Dungeon) -> State {
State {
@@ -27,8 +25,9 @@ impl State {
pub fn init(&mut self) {
self.dungeon.generate();
- self.player.place(self.current_level().get_start_point());
self.switch_level(0);
+ eprintln!("{:?}", self.current_level().get_start_point());
+ self.player.place(self.current_level().get_start_point());
}
pub fn switch_level(&mut self, num_level: usize) {
@@ -36,47 +35,51 @@ impl State {
self.grid = Some(self.current_level().to_tilegrid().unwrap());
}
- pub fn render_level(&self, window: &Window) {
+ pub fn render_level(&self) {
+ let mut sout = stdout();
for (linenum, line) in self.grid.as_ref().unwrap().raw_data().iter().enumerate() {
- for block in line.iter() {
- draw_block(&window, &block);
+ let linestr = line.iter().map(tile_to_str).collect::<Vec<&str>>();
+ let mut linestr2 = String::from("");
+ for chr in linestr {
+ linestr2.push_str(chr);
}
- window.mv(linenum as i32, 0);
+ queue!(
+ sout,
+ Output(linestr2),
+ MoveTo(0, linenum as u16)
+ ).unwrap();
+ sout.flush().unwrap();
}
}
- fn render_entity(&self, entity: &dyn Entity, window: &Window) {
+ fn render_entity(&self, entity: &dyn Entity) {
if !entity.is_dirty() {
return;
}
let dirt = entity.get_previous_location();
- window.mv(dirt.1 as i32, dirt.0 as i32);
- draw_block(
- window,
- self.grid.as_ref().unwrap().get_block_at(dirt.0, dirt.1),
- );
- window.mv(
- entity.get_location().1 as i32,
- entity.get_location().0 as i32,
- );
- draw_block(window, entity.get_tiletype());
+ let background = self.grid.as_ref().unwrap().get_block_at(dirt.0, dirt.1);
+ let mut sout = stdout();
+ queue!(
+ sout,
+ MoveTo(dirt.0 as u16, dirt.1 as u16),
+ Output(tile_to_str(background)),
+ MoveTo(entity.get_location().0 as u16, entity.get_location().1 as u16),
+ Output(tile_to_str(entity.get_tiletype()))
+ ).unwrap();
+ sout.flush().unwrap();
}
- pub fn render_entities(&self, window: &Window) {
+ pub fn render_entities(&self) {
for e in self.current_level().entities.iter() {
- self.render_entity(&**e, window);
+ self.render_entity(&**e);
}
}
- pub fn render_player(&self, window: &Window) {
- self.render_entity(&self.player, window)
+ pub fn render_player(&self) {
+ self.render_entity(&self.player)
}
pub fn current_level(&self) -> &Level {
&self.dungeon.levels[self.level]
}
-
- pub fn get_player_mut(&mut self) -> &mut Character {
- &mut self.player
- }
}
diff --git a/src/tiling.rs b/src/tiling.rs
index 2b6da80..fa00464 100644
--- a/src/tiling.rs
+++ b/src/tiling.rs
@@ -1,5 +1,3 @@
-extern crate pancurses;
-
pub struct TileGrid {
grid: Vec<Vec<TileType>>,
}
diff --git a/src/world.rs b/src/world.rs
index 99e5ca9..96c928d 100644
--- a/src/world.rs
+++ b/src/world.rs
@@ -295,7 +295,7 @@ impl Level {
}
pub fn get_start_point(&self) -> Point {
- if self.rooms.is_empty() {
+ if !self.rooms.is_empty() {
return self.rooms[0].center;
}
(0, 0)