Skip to content
Snippets Groups Projects
Commit 392d1155 authored by pumapaul's avatar pumapaul
Browse files

wip user turn

parent a6dc04e0
Branches
No related tags found
No related merge requests found
......@@ -38,10 +38,7 @@ impl GameState {
impl State for GameState {
fn update(&mut self, ctx: &mut Context) -> tetra::Result {
let keys = input::get_keys_pressed(ctx);
for key in keys {
println!("{:?}", key);
}
GameState::handle_user_turn(ctx);
Ok(())
}
......@@ -54,6 +51,36 @@ impl State for GameState {
}
}
// USER TURN
impl GameState {
/**
RETURNS:
true <-> user took their turn -> continue with enemy turn!
false <-> user didn't do anything or produced an error (moved into wall, etc)
*/
fn handle_user_turn(ctx: &mut Context) -> bool {
let key = GameState::get_pressed_key(ctx);
return match key {
Key::CapsLock => false,
_ => {
println!("{:?}", key);
true
}
}
}
fn get_pressed_key(ctx: &mut Context) -> Key {
let keys = input::get_keys_pressed(ctx);
let mut result = input::Key::CapsLock;
for key in keys {
result = *key
}
result
}
}
// DRAWING HELPERS
impl GameState {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment