diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index c3a02e9..9b313be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,11 +9,16 @@ pub mod gameserver; pub mod room; pub mod util; pub mod controls; +pub mod assemblages; +pub mod components; +pub mod resources; +pub mod systems; use self::gameserver::{GameServer, Action}; use self::server::unixserver::UnixServer; use self::server::tcpserver::TcpServer; use self::server::Server; +use self::assemblages::{Player, Wall, Grass}; use serde_json; @@ -34,11 +39,13 @@ fn main() { let mut room = room::Room::new((32, 32)); + gen_room(&mut room); + loop { let actions = gameserver.update(); for action in actions { match action { - Action::Join(name) => {room.add_player(&name);} + Action::Join(name) => {room.add_player(&name, &Player::new(&name));} Action::Leave(name) => {room.remove_player(&name);} Action::Input(name, control) => {room.control(name, control);} } @@ -51,6 +58,24 @@ fn main() { } } +fn gen_room(room: &mut room::Room){ + + let (width, height) = room.get_size(); + for x in 0..width { + room.add_obj(&Wall, (x, 0)); + room.add_obj(&Wall, (x, height - 1)); + } + for y in 1..height-1 { + room.add_obj(&Wall, (0, y)); + room.add_obj(&Wall, (width - 1, y)); + } + for x in 1..width-1 { + for y in 1..height-1 { + room.add_obj(&Grass::new(), (x, y)); + } + } +} + fn create_update_message((width, height): (i32, i32), field: Vec<usize>, mapping: Vec<Vec<String>>) -> String { let updatemsg= serde_json::json!([ |
