From 60c19f7d14ec61b85b60b994d7db6505c21f4dfa Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Sat, 3 Oct 2015 01:02:13 +0200 Subject: [PATCH] working towards something that starts --- src/main.rs | 4 +++- src/manager.rs | 0 src/worker.rs | 0 src/world.rs | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) delete mode 100644 src/manager.rs delete mode 100644 src/worker.rs create mode 100644 src/world.rs diff --git a/src/main.rs b/src/main.rs index c72eff6..539a85d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ mod action; mod block; mod structure; +mod world; + fn main() { - println!("Hello, world!"); + } diff --git a/src/manager.rs b/src/manager.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/worker.rs b/src/worker.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/world.rs b/src/world.rs new file mode 100644 index 0000000..a545746 --- /dev/null +++ b/src/world.rs @@ -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>, // access a structure using coordinates + structures: Vec // list of all structures +} + +impl World { + pub fn new(size: i32) -> World { + World { + size: size, + grid: Vec::new() as Vec>, + structures: Vec::new() as Vec, + } + } + 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) } + } +}