From e5bbb23389ccbda1e7f29fdfbd148a20bb23ccd8 Mon Sep 17 00:00:00 2001 From: Emirhan Yener <97049246+emirhanyener@users.noreply.github.com> Date: Thu, 23 Jun 2022 21:07:30 +0300 Subject: [PATCH] examples: fix 2048 gameplay (#14838) --- examples/2048/2048.v | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/2048/2048.v b/examples/2048/2048.v index 5e1021199a..bf8bf6d88e 100644 --- a/examples/2048/2048.v +++ b/examples/2048/2048.v @@ -787,7 +787,7 @@ fn (mut app App) undo() { fn (mut app App) on_key_down(key gg.KeyCode) { // these keys are independent from the game state: match key { - .a { app.is_ai_mode = !app.is_ai_mode } + .c { app.is_ai_mode = !app.is_ai_mode } .escape { app.gg.quit() } .n, .r { app.new_game() } .backspace { app.undo() } @@ -797,12 +797,14 @@ fn (mut app App) on_key_down(key gg.KeyCode) { else {} } if app.state in [.play, .freeplay] { - match key { - .w, .up { app.move(.up) } - .a, .left { app.move(.left) } - .s, .down { app.move(.down) } - .d, .right { app.move(.right) } - else {} + if !app.is_ai_mode { + match key { + .w, .up { app.move(.up) } + .a, .left { app.move(.left) } + .s, .down { app.move(.down) } + .d, .right { app.move(.right) } + else {} + } } } if app.state == .victory {