Browse Source

Basic setup for World

master
Graham Northup 3 years ago
parent
commit
33bbb6eb93
Signed by untrusted user: grissess GPG Key ID: 5D000E6F539376FB
  1. 5
      src/main.rs
  2. 0
      src/world/gen.rs
  3. 54
      src/world/mod.rs
  4. 0
      src/world/render.rs

5
src/main.rs

@ -1,6 +1,7 @@
use rogue_util::{coord::V2i, grid::region::{Region, RegionConfig}};
extern crate termion;
extern crate rogue_util;
struct Tile();
use rogue_util::{coord::V2i, grid::region::{Region, RegionConfig}};
fn main() -> Result<(), rogue_util::grid::region::Error>
{

0
src/world/gen.rs

54
src/world/mod.rs

@ -0,0 +1,54 @@
pub mod render;
pub mod gen;
use rogue_util::{coord::*, grid::region::{Region, RegionConfig}};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Content {
Air,
Stone,
}
impl Default for Content {
fn default() -> Content {
Content::Stone
}
}
#[derive(Debug, Clone)]
pub struct Tile {
pub content: Content,
}
impl Default for Tile {
fn default() -> Tile {
Tile {
content: Default::default(),
}
}
}
#[derive(Debug)]
pub struct World {
cur_region: usize,
regions: Vec<Region<Tile>>,
}
impl World {
pub fn new() -> World {
let start_region = RegionConfig::default().build().expect("Failed to make World");
// TODO: Worldgen on start_region
World {
cur_region: 0,
regions: vec![start_region],
}
}
pub fn region(&self) -> &Region<Tile> {
&self.regions[self.cur_region]
}
pub fn region_mut(&mut self) -> &mut Region<Tile> {
&mut self.regions[self.cur_region]
}
}

0
src/world/render.rs

Loading…
Cancel
Save