working towards something that starts
This commit is contained in:
parent
5005bc17cf
commit
60c19f7d14
@ -3,6 +3,8 @@ mod action;
|
|||||||
mod block;
|
mod block;
|
||||||
mod structure;
|
mod structure;
|
||||||
|
|
||||||
|
mod world;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
}
|
||||||
|
35
src/world.rs
Normal file
35
src/world.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use structure::Structure;
|
||||||
|
use action::Action;
|
||||||
|
use util::Point;
|
||||||
|
use std::sync::mpsc::{Sender,Receiver,channel};
|
||||||
|
|
||||||
|
pub struct World {
|
||||||
|
size: i32, // width and height of the grid
|
||||||
|
grid: Vec<Option<Structure>>, // access a structure using coordinates
|
||||||
|
structures: Vec<Structure> // list of all structures
|
||||||
|
}
|
||||||
|
|
||||||
|
impl World {
|
||||||
|
pub fn new(size: i32) -> World {
|
||||||
|
World {
|
||||||
|
size: size,
|
||||||
|
grid: Vec::new() as Vec<Option<Structure>>,
|
||||||
|
structures: Vec::new() as Vec<Structure>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn compute(&mut self) {
|
||||||
|
|
||||||
|
}
|
||||||
|
pub fn fix_coords(&self, p: Point) -> Point {
|
||||||
|
fn fix_coord(c: i32, limit: i32) -> i32 {
|
||||||
|
match c < 0 {
|
||||||
|
true => (c * -1) % limit,
|
||||||
|
false => match c >= limit {
|
||||||
|
true => c % limit,
|
||||||
|
false => c
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Point { x: fix_coord(p.x,self.size), y: fix_coord(p.y,self.size) }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user