From dad11c774fe42885987bf74fe2bb567c2d8029f0 Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Fri, 10 Apr 2020 15:47:14 +0200 Subject: Skeleton for game state updates --- src/main.rs | 1 + src/state.rs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/state.rs diff --git a/src/main.rs b/src/main.rs index 5d29529..a565e73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use std::io::stdin; mod command; mod json; +mod state; use command::*; use json::*; diff --git a/src/state.rs b/src/state.rs new file mode 100644 index 0000000..2f81d5d --- /dev/null +++ b/src/state.rs @@ -0,0 +1,37 @@ +use crate::command::Command; + +pub struct GameState { + players: [Player; 2], +} + +pub struct Player {} +impl GameState { + fn update(&mut self, commands: [Command; 2]) { + self.do_command(0, &commands[0]); + self.do_command(1, &commands[1]); + self.update_player_collisions(); + self.update_player_travel(); + } + + fn do_command(&mut self, player_index: usize, command: &Command) { + use Command::*; + + match command { + Nothing => {} + Accelerate => unimplemented!(), + Decelerate => unimplemented!(), + TurnLeft => unimplemented!(), + TurnRight => unimplemented!(), + UseBoost => unimplemented!(), + UseOil => unimplemented!(), + } + } + + fn update_player_collisions(&mut self) { + //TODO + } + + fn update_player_travel(&mut self) { + //TODO + } +} -- cgit v1.2.3