aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2019-07-06 11:11:51 +0100
committerGuillaume Pasquet <dev@etenil.net>2019-07-06 11:11:51 +0100
commitdb23cf1e9ffdb127f9a6b1540edcbfc4ea12e3b6 (patch)
treed571cd5030a9bcf805f7259f27f3490989f69775 /src/main.rs
parent7abfab104ffa052d885eb7d333f0569dc61ab74c (diff)
Make corridors
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs75
1 files changed, 30 insertions, 45 deletions
diff --git a/src/main.rs b/src/main.rs
index 65ada01..7edc654 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,61 +10,46 @@ mod world;
use character::Player;
use computer::Enemy;
-use pancurses::{initscr, endwin};
+use pancurses::{Window, initscr, endwin};
use rand::Rng;
use std::io;
+use std::convert::TryFrom;
+use world::{World, GameWorld, BlockType};
-fn main() {
- let window = initscr();
- window.printw("Hello Rust");
- window.refresh();
- window.mv(2, 2);
- window.printw("toto");
- window.refresh();
- window.getch();
- endwin();
-}
- // println!(
- // "=== Welcome to RRL {} the {}! ===\n",
- // env!("CARGO_PKG_DESCRIPTION"), env!("CARGO_PKG_VERSION")
- // );
-
- // let characters: [character::Character; 5] = [
- // character::Character::new("".to_string(), "Cleric".to_string(), 7, 5, 6, 7),
- // character::Character::new("".to_string(), "Warrior".to_string(), 10, 5, 5, 5),
- // character::Character::new("".to_string(), "Hunter".to_string(), 5, 7, 7, 6),
- // character::Character::new("".to_string(), "Wizard".to_string(), 3, 10, 5, 7),
- // character::Character::new("".to_string(), "Thief".to_string(), 4, 5, 6, 10),
- // ];
+fn draw_block(window: &Window, block: &BlockType) {
+ let repr = match block {
+ BlockType::Floor => ".",
+ BlockType::Wall => "0",
+ BlockType::Nothing => " "
+ };
- // let _luck_amount = rand::thread_rng().gen_range(2, 6);
+ print!("{}", repr);
- // println!("You enter the Ephemeral Plane of Creation...");
- // println!("Please enter your name.");
+ window.printw(repr);
+}
- // let mut input_text = String::new();
+fn render_world(window: &Window, world: &World) {
+ let grid = world.get_world();
- // io::stdin()
- // .read_line(&mut input_text)
- // .expect("Failed to read line");
- // let _character_name = input_text.trim();
+ for (linenum, line) in grid.iter().enumerate() {
+ for block in line.iter() {
+ draw_block(&window, block);
+ }
+ window.mv(linenum as i32, 0);
+ println!("");
+ }
+}
- // println!("Please select your character type:");
- // for (i, elem) in characters.iter().enumerate() {
- // print!("\n{}. {}\n\n", i + 1, elem.info());
- // }
+fn main() {
+ let mut world = World::new(30);
+ world.generate();
- // let mut character_index: usize = 100;
- // while character_index > characters.len() {
- // character_index = read!();
- // }
+ let window = initscr();
- // let mut player = characters[character_index].select(_character_name.to_string(), _luck_amount);
+ render_world(&window, &world);
- // play(&mut player);
-// }
+ window.refresh();
-fn play(player: &mut character::Character) {
- println!("=== Welcome to RRL {} the {}! ===\n", player.name, player.class);
- println!("Your unique stats: {}", player.stats());
+ window.getch();
+ endwin();
}