]> git.lizzy.rs Git - nothing.git/commitdiff
(#1060) Add CTRL+q shortcut to quit the game
authorrexim <reximkut@gmail.com>
Sun, 15 Sep 2019 18:48:19 +0000 (01:48 +0700)
committerrexim <reximkut@gmail.com>
Sun, 15 Sep 2019 18:56:06 +0000 (01:56 +0700)
README.md
src/game.c

index 283aa5a50ad3a2bdd0c632f51178d62de152137f..67dde2d8758e974ed0d166e999b9d8a9c0c9a673 100644 (file)
--- a/README.md
+++ b/README.md
@@ -123,17 +123,18 @@ $ ../build/nothing
 
 #### Keyboard
 
-| Key     | Action                                                      |
-|---------|-------------------------------------------------------------|
-| `d`     | Move to the right                                           |
-| `a`     | Move to the left                                            |
-| `SPACE` | Jump                                                        |
-| `c`     | Open debug console                                          |
-| `r`     | Reload the current level including the Player's position    |
-| `q`     | Reload the current level preserving the Player's position   |
-| `p`     | Toggle game pause                                           |
-| `l`     | Toggle transparency on objects. Useful for debugging levels |
-| `TAB`   | Switch to Level Editor                                      |
+| Key      | Action                                                      |
+|----------|-------------------------------------------------------------|
+| `d`      | Move to the right                                           |
+| `a`      | Move to the left                                            |
+| `SPACE`  | Jump                                                        |
+| `c`      | Open debug console                                          |
+| `r`      | Reload the current level including the Player's position    |
+| `q`      | Reload the current level preserving the Player's position   |
+| `p`      | Toggle game pause                                           |
+| `l`      | Toggle transparency on objects. Useful for debugging levels |
+| `TAB`    | Switch to Level Editor                                      |
+| `CTRL+q` | Quit the game                                               |
 
 #### Gamepad
 
index c991757b852a82c0c249b4c1b189b2f88d8feed8..76c5cce77d77aa4bc36773a412967585d3eba9fd 100644 (file)
@@ -404,6 +404,13 @@ int game_event(Game *game, const SDL_Event *event)
         game->cursor_x = event->motion.x;
         game->cursor_y = event->motion.y;
     } break;
+
+    case SDL_KEYDOWN: {
+        if (event->key.keysym.sym == SDLK_q && event->key.keysym.mod & KMOD_CTRL) {
+            game_switch_state(game, GAME_STATE_QUIT);
+            return 0;
+        }
+    } break;
     }
 
     switch (game->state) {