Skip to content
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

Merged
merged 5 commits into from
Apr 4, 2024
Merged

Actions #4

merged 5 commits into from
Apr 4, 2024

Conversation

bingoobongoo
Copy link
Contributor

Implemented basic system for managing in-game actions and sdl events.

@bingoobongoo bingoobongoo self-assigned this Mar 30, 2024
@bingoobongoo bingoobongoo requested a review from stabor705 March 30, 2024 10:26
Copy link
Collaborator

@stabor705 stabor705 left a 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

}

impl Action {
pub fn check_click_grid_cell(x: i32, y: i32) -> Option<Self> {
Copy link
Collaborator

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

Copy link
Contributor Author

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.


fn match_input(sdl_ev: Event) -> Option<Action> {
match sdl_ev {
Event::KeyDown { keycode, .. } => Self::match_key_down(keycode.unwrap()),
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Collaborator

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

Copy link
Contributor Author

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()

@bingoobongoo bingoobongoo requested a review from stabor705 April 2, 2024 08:38
Copy link

@vLesio vLesio left a 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.

@bingoobongoo bingoobongoo merged commit 9e970e7 into master Apr 4, 2024
8 checks passed
@bingoobongoo bingoobongoo deleted the actions branch April 4, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants