-
-
Notifications
You must be signed in to change notification settings - Fork 148
Added R key to reset game #350
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
Changes from 6 commits
e09c221
aa94512
42f82d7
b7fe9bb
04f9100
62359c5
9a545f7
2d68f03
93d0a1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,10 @@ impl Game { | |
| Controls { direction, fire } | ||
| }; | ||
| } | ||
|
|
||
| fn reset_game(&mut self) { | ||
| self.world.reset_game(); | ||
| } | ||
| } | ||
|
|
||
| fn main() -> Result<(), Error> { | ||
|
|
@@ -165,6 +169,11 @@ fn main() -> Result<(), Error> { | |
| return; | ||
| } | ||
|
|
||
| // Reset game | ||
| if g.game.input.key_pressed(VirtualKeyCode::R) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a binding for controller inputs as well. Maybe the "select" button? I don't actually know what it's called any more on XBox/PS/Switch!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the "select" button? I don't know!LOL ; ) But I believe that if add the selected operation interface, this problem will be solved! |
||
| g.game.reset_game(); | ||
| } | ||
|
|
||
| // Resize the window | ||
| if let Some(size) = g.game.input.window_resized() { | ||
| if let Err(err) = g.game.pixels.resize_surface(size.width, size.height) { | ||
|
|
||
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.
We should probably move these magic numbers to
constvalues at global (module) scope. If they need to be reused in multiple modules, we can create acrate::constsmodule for them.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.
LGTM