Compare commits
No commits in common. "6b6a6720cee7b8662b6c519dc07e9b77332bdc0c" and "0ec5fbbe8cd4cb0d792dfd8508d0d87ca05ebe47" have entirely different histories.
6b6a6720ce
...
0ec5fbbe8c
|
@ -4,6 +4,24 @@ use pancurses::Window;
|
||||||
|
|
||||||
use crate::rooms;
|
use crate::rooms;
|
||||||
|
|
||||||
|
/// A dungeon root.
|
||||||
|
pub struct Dungeon {
|
||||||
|
main_branch: DungeonBranch,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A single branch of a dungeon, which has a number of levels and
|
||||||
|
/// which can potentially contain passages to other branches.
|
||||||
|
pub struct DungeonBranch {
|
||||||
|
config: BranchConfig,
|
||||||
|
levels: Vec<DungeonLevel>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The parameters that characterize a particular dungeon branch.
|
||||||
|
/// Currently a unit struct because there's only one type of branch,
|
||||||
|
/// but will later include e.g. architectural styles, good vs. evil &
|
||||||
|
/// lawful vs. chaotic weights, etc.
|
||||||
|
pub struct BranchConfig;
|
||||||
|
|
||||||
/// The size of a dungeon level, in tiles.
|
/// The size of a dungeon level, in tiles.
|
||||||
pub const LEVEL_SIZE: (usize, usize) = (80, 24);
|
pub const LEVEL_SIZE: (usize, usize) = (80, 24);
|
||||||
|
|
||||||
|
@ -33,7 +51,10 @@ pub enum DungeonTile {
|
||||||
impl DungeonLevel {
|
impl DungeonLevel {
|
||||||
/// Creates a new level in a branch that has the given
|
/// Creates a new level in a branch that has the given
|
||||||
/// configuration.
|
/// configuration.
|
||||||
pub fn new() -> Self {
|
pub fn new(_cfg: &BranchConfig) -> Self {
|
||||||
|
// Self {
|
||||||
|
// tiles: rooms::generate_level(100, &mut rand::thread_rng()),
|
||||||
|
// }
|
||||||
rooms::generate_level(100, &mut rand::thread_rng(), 1, 1)
|
rooms::generate_level(100, &mut rand::thread_rng(), 1, 1)
|
||||||
}
|
}
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,7 +1,7 @@
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use components::{register_all, CharRender, MobAction, Mobile, Player, Position, TurnTaker};
|
use components::{register_all, CharRender, MobAction, Mobile, Player, Position, TurnTaker};
|
||||||
use level::DungeonLevel;
|
use game::{BranchConfig, DungeonLevel};
|
||||||
|
|
||||||
use pancurses::{endwin, initscr, noecho, Window};
|
use pancurses::{endwin, initscr, noecho, Window};
|
||||||
use player::player_turn;
|
use player::player_turn;
|
||||||
|
@ -9,7 +9,7 @@ use specs::prelude::*;
|
||||||
use systems::{MobSystem, TimeSystem};
|
use systems::{MobSystem, TimeSystem};
|
||||||
|
|
||||||
mod components;
|
mod components;
|
||||||
mod level;
|
mod game;
|
||||||
mod player;
|
mod player;
|
||||||
mod rooms;
|
mod rooms;
|
||||||
mod systems;
|
mod systems;
|
||||||
|
@ -20,17 +20,15 @@ fn main() {
|
||||||
|
|
||||||
register_all(&mut world);
|
register_all(&mut world);
|
||||||
|
|
||||||
let level = DungeonLevel::new();
|
let cfg = BranchConfig;
|
||||||
|
let level = DungeonLevel::new(&cfg);
|
||||||
let spawn_pos = level.upstairs()[0];
|
let spawn_pos = level.upstairs()[0];
|
||||||
|
|
||||||
world.insert(level);
|
world.insert(level);
|
||||||
|
|
||||||
world
|
world
|
||||||
.create_entity()
|
.create_entity()
|
||||||
.with(Position {
|
.with(Position { x: spawn_pos.0, y: spawn_pos.1 })
|
||||||
x: spawn_pos.0,
|
|
||||||
y: spawn_pos.1,
|
|
||||||
})
|
|
||||||
.with(CharRender { glyph: '@' })
|
.with(CharRender { glyph: '@' })
|
||||||
.with(Player)
|
.with(Player)
|
||||||
.with(Mobile {
|
.with(Mobile {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use specs::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
components::{CharRender, MobAction, Mobile, Player, Position},
|
components::{CharRender, MobAction, Mobile, Player, Position},
|
||||||
level::{DungeonLevel, DungeonTile},
|
game::{DungeonLevel, DungeonTile},
|
||||||
quit,
|
quit,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use pathfinding::directed::astar::astar;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
level::{DungeonLevel, DungeonTile, LEVEL_SIZE},
|
game::{DungeonLevel, DungeonTile, LEVEL_SIZE},
|
||||||
util::NiceFloat,
|
util::NiceFloat,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue