Skip to content

Commit

Permalink
Update to 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
whostolemyhat committed Sep 24, 2019
1 parent 6db5557 commit 4421043
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 40 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
authors = ["James Baum <[email protected]>"]
name = "dungeon"
version = "2.0.1"
version = "3.0.0"
edition = "2018"

[dependencies]
arrayref = "0.3.4"
Expand Down
14 changes: 3 additions & 11 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
extern crate rand;
extern crate sha2;
#[macro_use]
extern crate arrayref;
extern crate serde;
extern crate serde_json;
extern crate clap;

extern crate dungeon;
use arrayref::array_ref;
use dungeon::{ roomscorridors, bsp, draw };

use sha2::{ Sha256, Digest };
Expand Down Expand Up @@ -39,7 +31,7 @@ fn main() {
// max rooms
// room size
let matches = App::new("Dungeon")
.version("1.0")
.version("3.0")
.author("James Baum <@whostolemyhat>")
.arg(Arg::with_name("text")
.short("t")
Expand Down Expand Up @@ -165,4 +157,4 @@ fn main() {
// cellular automata https://gamedevelopment.tutsplus.com/tutorials/generate-random-cave-levels-using-cellular-automata--gamedev-9664
// bsp https://gamedevelopment.tutsplus.com/tutorials/how-to-use-bsp-trees-to-generate-game-maps--gamedev-12268

// http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php
// http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php
9 changes: 4 additions & 5 deletions src/bsp.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// https://gamedevelopment.tutsplus.com/tutorials/how-to-use-bsp-trees-to-generate-game-maps--gamedev-12268
use rand::{ Rng, StdRng };
use room::{ Room };

use level::Level;

use tile::Tile;
use crate::room::{ Room };
use crate::level::Level;
use crate::tile::Tile;

pub struct BspLevel {
level: Level
Expand Down Expand Up @@ -318,4 +317,4 @@ impl<'a> Iterator for LeafIterator<'a> {
None => None
}
}
}
}
8 changes: 3 additions & 5 deletions src/draw.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
extern crate cairo;

use level::{ Level };
use tile::Tile;
use crate::level::{ Level };
use crate::tile::Tile;
use std::fs::File;
use self::cairo::{ Context, Format, ImageSurface };
use cairo::{ Context, Format, ImageSurface };

fn draw_tile(context: &Context, x: f64, y: f64, x2: f64, y2: f64, colour: (f64, f64, f64)) {
// context.set_source_rgb(0.258, 0.525, 0.956);
Expand Down
6 changes: 4 additions & 2 deletions src/level.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::fmt;
use room::Room;
use tile::Tile;
use serde_derive::Serialize;

use crate::room::Room;
use crate::tile::Tile;

#[derive(Serialize)]
pub struct Level {
Expand Down
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
extern crate rand;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;

pub mod draw;
pub mod tile;
pub mod level;
Expand Down
8 changes: 5 additions & 3 deletions src/room.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use tile::Tile;
use serde_derive::Serialize;

use crate::tile::Tile;

#[derive(Debug, Clone, Copy, Serialize)]
pub struct Point {
Expand Down Expand Up @@ -68,8 +70,8 @@ impl Room {

#[cfg(test)]
mod tests {
use room::Room;
use tile::Tile;
use crate::room::Room;
use crate::tile::Tile;

#[test]
fn test_new_room() {
Expand Down
8 changes: 4 additions & 4 deletions src/roomscorridors.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use rand::{ Rng, StdRng };

use level::Level;
use room::Room;
use tile::Tile;
use crate::level::Level;
use crate::room::Room;
use crate::tile::Tile;

pub struct RoomsCorridors {
level: Level
Expand Down Expand Up @@ -111,4 +111,4 @@ impl RoomsCorridors {
// draw(&self, "./img", format!("{}", i + 11).as_str()).unwrap();
}
}
}
}
4 changes: 2 additions & 2 deletions src/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Serialize for Tile {

#[cfg(test)]
mod tests {
use tile::Tile;
use crate::tile::Tile;
use serde_json;

#[test]
Expand All @@ -44,4 +44,4 @@ mod tests {
assert_eq!(serde_json::to_string(&Tile::Empty).unwrap(), "0");
assert_eq!(serde_json::to_string(&Tile::Walkable).unwrap(), "1");
}
}
}

0 comments on commit 4421043

Please sign in to comment.