-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actions #4
Actions #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! Do the cosmetic changes I requested and we can merge
bdi_game/src/display/actions.rs
Outdated
} | ||
|
||
impl Action { | ||
pub fn check_click_grid_cell(x: i32, y: i32) -> Option<Self> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go with something like from_click
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it to from_left_click
in case we want to use right mouse button later.
bdi_game/src/display/actions.rs
Outdated
|
||
fn match_input(sdl_ev: Event) -> Option<Action> { | ||
match sdl_ev { | ||
Event::KeyDown { keycode, .. } => Self::match_key_down(keycode.unwrap()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid .unwrap()
at all cost :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added if keycode.is_some()
match guard so it always works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try if Event::KeyDown { Some(keycode), .. }
works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, i get error, keycode
itself is of type Option, so there is no point in wrapping it in Some()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test comment on PR to trigger GitHub bot.
Implemented basic system for managing in-game actions and sdl events.