Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rustproject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
safarik
rustproject
Commits
392d1155
Commit
392d1155
authored
4 years ago
by
pumapaul
Browse files
Options
Downloads
Patches
Plain Diff
wip user turn
parent
a6dc04e0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/game_state.rs
+31
-4
31 additions, 4 deletions
src/game_state.rs
with
31 additions
and
4 deletions
src/game_state.rs
+
31
−
4
View file @
392d1155
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment