mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: fix 2048 gameplay (#14838)
This commit is contained in:
parent
c10ba6d81a
commit
e5bbb23389
@ -787,7 +787,7 @@ fn (mut app App) undo() {
|
|||||||
fn (mut app App) on_key_down(key gg.KeyCode) {
|
fn (mut app App) on_key_down(key gg.KeyCode) {
|
||||||
// these keys are independent from the game state:
|
// these keys are independent from the game state:
|
||||||
match key {
|
match key {
|
||||||
.a { app.is_ai_mode = !app.is_ai_mode }
|
.c { app.is_ai_mode = !app.is_ai_mode }
|
||||||
.escape { app.gg.quit() }
|
.escape { app.gg.quit() }
|
||||||
.n, .r { app.new_game() }
|
.n, .r { app.new_game() }
|
||||||
.backspace { app.undo() }
|
.backspace { app.undo() }
|
||||||
@ -797,12 +797,14 @@ fn (mut app App) on_key_down(key gg.KeyCode) {
|
|||||||
else {}
|
else {}
|
||||||
}
|
}
|
||||||
if app.state in [.play, .freeplay] {
|
if app.state in [.play, .freeplay] {
|
||||||
match key {
|
if !app.is_ai_mode {
|
||||||
.w, .up { app.move(.up) }
|
match key {
|
||||||
.a, .left { app.move(.left) }
|
.w, .up { app.move(.up) }
|
||||||
.s, .down { app.move(.down) }
|
.a, .left { app.move(.left) }
|
||||||
.d, .right { app.move(.right) }
|
.s, .down { app.move(.down) }
|
||||||
else {}
|
.d, .right { app.move(.right) }
|
||||||
|
else {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if app.state == .victory {
|
if app.state == .victory {
|
||||||
|
Loading…
Reference in New Issue
Block a user