diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2020-04-10 15:47:14 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2020-04-10 15:47:14 +0200 |
commit | dad11c774fe42885987bf74fe2bb567c2d8029f0 (patch) | |
tree | 12e74abb017aa2089aeebc8354fca8c292f6061a /src/state.rs | |
parent | 34403b2cc05b8376261aa00b048a4697bcb62d87 (diff) |
Skeleton for game state updates
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 37 |
1 files changed, 37 insertions, 0 deletions
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 + } +} |