From 62a9f02879a3ce52e94cdfb8296b1bd7e0588d5e Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Tue, 12 Mar 2024 16:21:50 +0100 Subject: [PATCH] add keybind --- README.md | 9 +++++++++ main.c | 27 +++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4eafaf2..9ad8f13 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,15 @@ Minesweeper game. Oh no, my os doesn't comme with minesweeper preinstalled, let's make it myself. +# Keybind + +- q / escape : close app +- r : reset grid +- b : switch to beginner difficulty +- i : switch to intermediate difficulty +- e : switch to expert difficulty +- s : take a screenshot (not working everywhere, not sure why) + # building You need to install [raylib v5](https://github.com/raysan5/raylib/releases/tag/5.0), but any version should work. diff --git a/main.c b/main.c index 3cc6b7d..8e73602 100644 --- a/main.c +++ b/main.c @@ -238,13 +238,36 @@ int main(void) { ClearBackground(BLACK); - if (IsKeyPressed(KEY_R)) { + if (IsKeyPressed(KEY_S)) { + TakeScreenshot("minesweeper-screenshot.png"); + } + + if (IsKeyPressed(KEY_A)) { + CloseWindow(); + exit(0); + } + + int resize = 0; + if (IsKeyPressed(KEY_I)) { + current_game_type = INTERMEDIATE; + resize = 1; + } + if (IsKeyPressed(KEY_B)) { + current_game_type = BEGINNER; + resize = 1; + } + if (IsKeyPressed(KEY_E)) { + current_game_type = EXPERT; + resize = 1; + } + if (resize || IsKeyPressed(KEY_R)) { game_state = PLAYING; memset(game, 0, game_cap); memset(discover, 0, game_cap); memset(zero, 0, game_cap); fill_game(); - + screen_resize_handle(); + resize = 0; } Color menu_color;