add keybind
This commit is contained in:
parent
0383e2099e
commit
62a9f02879
|
@ -4,6 +4,15 @@ Minesweeper game.
|
||||||
|
|
||||||
Oh no, my os doesn't comme with minesweeper preinstalled, let's make it myself.
|
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
|
# building
|
||||||
|
|
||||||
You need to install [raylib v5](https://github.com/raysan5/raylib/releases/tag/5.0), but any version should work.
|
You need to install [raylib v5](https://github.com/raysan5/raylib/releases/tag/5.0), but any version should work.
|
||||||
|
|
27
main.c
27
main.c
|
@ -238,13 +238,36 @@ int main(void)
|
||||||
{
|
{
|
||||||
ClearBackground(BLACK);
|
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;
|
game_state = PLAYING;
|
||||||
memset(game, 0, game_cap);
|
memset(game, 0, game_cap);
|
||||||
memset(discover, 0, game_cap);
|
memset(discover, 0, game_cap);
|
||||||
memset(zero, 0, game_cap);
|
memset(zero, 0, game_cap);
|
||||||
fill_game();
|
fill_game();
|
||||||
|
screen_resize_handle();
|
||||||
|
resize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color menu_color;
|
Color menu_color;
|
||||||
|
|
Loading…
Reference in New Issue