forked from snapshot112/minigame-menu
Code cleanup and documentation
This commit is contained in:
BIN
deel2.tar.gz
Normal file
BIN
deel2.tar.gz
Normal file
Binary file not shown.
92
grid.c
92
grid.c
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Created by snapshot112 on 2/10/2025
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -8,12 +13,15 @@
|
|||||||
* The grid type this program is build around.
|
* The grid type this program is build around.
|
||||||
*/
|
*/
|
||||||
typedef struct grid_data {
|
typedef struct grid_data {
|
||||||
char *rost;
|
char *locations;
|
||||||
int height;
|
int height;
|
||||||
int width;
|
int width;
|
||||||
state state;
|
state state;
|
||||||
} grid;
|
} grid;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Translate x and y coordinates to a location index on the grid.
|
||||||
|
*/
|
||||||
static int internal_location(const grid *gp, const int x, const int y) {
|
static int internal_location(const grid *gp, const int x, const int y) {
|
||||||
return y * (gp->width + 1) + x;
|
return y * (gp->width + 1) + x;
|
||||||
}
|
}
|
||||||
@@ -48,12 +56,12 @@ grid *grid_create_from_string(const char* input) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp->rost = malloc(grid_size * sizeof(char));
|
gp->locations = malloc(grid_size * sizeof(char));
|
||||||
gp->height = height;
|
gp->height = height;
|
||||||
gp->width = width;
|
gp->width = width;
|
||||||
gp->state = STATE_BEGIN;
|
gp->state = STATE_BEGIN;
|
||||||
|
|
||||||
strcpy(gp->rost, input);
|
strcpy(gp->locations, input);
|
||||||
|
|
||||||
return gp;
|
return gp;
|
||||||
}
|
}
|
||||||
@@ -62,8 +70,8 @@ grid *grid_create_from_string(const char* input) {
|
|||||||
* Sets a grids width and height
|
* Sets a grids width and height
|
||||||
*
|
*
|
||||||
* Input:
|
* Input:
|
||||||
* fh: the stream to read the grid from.
|
* fh: The stream to read the grid from.
|
||||||
* rost: a grid file to store the width and height in.
|
* gp: A pointer to the grid whose width and height you want to set.
|
||||||
*
|
*
|
||||||
* Side effects:
|
* Side effects:
|
||||||
* the grid gets its width and height set
|
* the grid gets its width and height set
|
||||||
@@ -72,27 +80,27 @@ grid *grid_create_from_string(const char* input) {
|
|||||||
* 1 if the file width and height seem to match with its size
|
* 1 if the file width and height seem to match with its size
|
||||||
* 0 otherwise
|
* 0 otherwise
|
||||||
*/
|
*/
|
||||||
static int get_grid_sizes(FILE *fh, grid *rost) {
|
static int get_grid_sizes(FILE *fh, grid *gp) {
|
||||||
while (getc(fh) != '\n') {
|
while (getc(fh) != '\n') {
|
||||||
if (feof(fh)) {
|
if (feof(fh)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rost->width++;
|
gp->width++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rost->width == 0) {
|
if (gp->width == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(fh, 0, SEEK_END);
|
fseek(fh, 0, SEEK_END);
|
||||||
|
|
||||||
// Get file size (- 1 for the blank newline and EOF at the end)
|
// Get file size (- 1 for the blank newline and EOF at the end)
|
||||||
if (ftell(fh) % (rost->width + 1) != 0) {
|
if (ftell(fh) % (gp->width + 1) != 0) {
|
||||||
// Not all lines are the same width
|
// Not all lines are the same width
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rost->height = (int)ftell(fh) / (int)sizeof(char) / (rost->width + 1);
|
gp->height = (int)ftell(fh) / (int)sizeof(char) / (gp->width + 1);
|
||||||
fseek(fh, 0, SEEK_SET);
|
fseek(fh, 0, SEEK_SET);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -103,7 +111,7 @@ grid *grid_create_from_file(FILE *fh) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
grid rost = {
|
grid temp_grid = {
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -111,52 +119,52 @@ grid *grid_create_from_file(FILE *fh) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Sets the width and height of the grid.
|
// Sets the width and height of the grid.
|
||||||
if (get_grid_sizes(fh, &rost) != 1) {
|
if (get_grid_sizes(fh, &temp_grid) != 1) {
|
||||||
// Unlogical file structure.
|
// Unlogical file structure.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int grid_size = (rost.width + 1) * rost.height + 1;
|
const int grid_size = (temp_grid.width + 1) * temp_grid.height + 1;
|
||||||
|
|
||||||
rost.rost = malloc(grid_size * sizeof(char));
|
temp_grid.locations = malloc(grid_size * sizeof(char));
|
||||||
if (rost.rost == NULL) {
|
if (temp_grid.locations == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This makes the strncat() work.
|
// This makes the strncat() work.
|
||||||
rost.rost[0] = '\0';
|
temp_grid.locations[0] = '\0';
|
||||||
|
|
||||||
char *line = malloc((rost.width + 2) * sizeof(char));
|
char *line = malloc((temp_grid.width + 2) * sizeof(char));
|
||||||
if (line == NULL) {
|
if (line == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < rost.height; i++) {
|
for (int i = 0; i < temp_grid.height; i++) {
|
||||||
if (fgets(line, rost.width + 2, fh) == NULL) {
|
if (fgets(line, temp_grid.width + 2, fh) == NULL) {
|
||||||
free(rost.rost);
|
free(temp_grid.locations);
|
||||||
free(line);
|
free(line);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate that the line length is correct
|
// Validate that the line length is correct
|
||||||
if ((int)strcspn(line, "\n") != rost.width) {
|
if ((int)strcspn(line, "\n") != temp_grid.width) {
|
||||||
free(rost.rost);
|
free(temp_grid.locations);
|
||||||
free(line);
|
free(line);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Width is without the newline at the end.
|
// Width is without the newline at the end.
|
||||||
strncat(rost.rost, line, rost.width + 1);
|
strncat(temp_grid.locations, line, temp_grid.width + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
grid *return_grid = malloc(sizeof(rost));
|
grid *return_grid = malloc(sizeof(temp_grid));
|
||||||
if (return_grid == NULL) {
|
if (return_grid == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(return_grid, &rost, sizeof(rost));
|
memcpy(return_grid, &temp_grid, sizeof(temp_grid));
|
||||||
|
|
||||||
return return_grid;
|
return return_grid;
|
||||||
}
|
}
|
||||||
@@ -192,9 +200,9 @@ void grid_put_state(grid *gp, const state t) {
|
|||||||
|
|
||||||
void grid_cleanup(grid *gp) {
|
void grid_cleanup(grid *gp) {
|
||||||
if (gp != NULL) {
|
if (gp != NULL) {
|
||||||
if (gp->rost != NULL)
|
if (gp->locations != NULL)
|
||||||
{
|
{
|
||||||
free(gp->rost);
|
free(gp->locations);
|
||||||
}
|
}
|
||||||
free(gp);
|
free(gp);
|
||||||
}
|
}
|
||||||
@@ -215,7 +223,7 @@ int grid_height(const grid *gp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int grid_contains(const grid *gp, const int x, const int y) {
|
int grid_contains(const grid *gp, const int x, const int y) {
|
||||||
if (gp != NULL && gp->rost != NULL) {
|
if (gp != NULL && gp->locations != NULL) {
|
||||||
if (x >= 0 && y >= 0 && x < gp->width && y < gp->height)
|
if (x >= 0 && y >= 0 && x < gp->width && y < gp->height)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
@@ -225,25 +233,25 @@ int grid_contains(const grid *gp, const int x, const int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char grid_fetch(const grid *gp, const int x, const int y) {
|
char grid_fetch(const grid *gp, const int x, const int y) {
|
||||||
if (gp != NULL && gp->rost != NULL && grid_contains(gp, x, y) == 1) {
|
if (gp != NULL && gp->locations != NULL && grid_contains(gp, x, y) == 1) {
|
||||||
return gp->rost[internal_location(gp, x, y)];
|
return gp->locations[internal_location(gp, x, y)];
|
||||||
}
|
}
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
int grid_put(grid *gp, const int x, const int y, const char c) {
|
int grid_put(grid *gp, const int x, const int y, const char c) {
|
||||||
if (gp != NULL && gp->rost != NULL && grid_contains(gp, x, y) == 1) {
|
if (gp != NULL && gp->locations != NULL && grid_contains(gp, x, y) == 1) {
|
||||||
gp->rost[internal_location(gp, x, y)] = c;
|
gp->locations[internal_location(gp, x, y)] = c;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *grid_fetch_row(const grid *gp, const int y) {
|
char *grid_fetch_row(const grid *gp, const int y) {
|
||||||
if (gp != NULL && gp->rost != NULL && grid_contains(gp, 0, y) == 1) {
|
if (gp != NULL && gp->locations != NULL && grid_contains(gp, 0, y) == 1) {
|
||||||
// we're going to remove the newline so this is long enough
|
// we're going to remove the newline so this is long enough
|
||||||
char *row = malloc((gp->width + 1) * sizeof(char));
|
char *row = malloc((gp->width + 1) * sizeof(char));
|
||||||
memcpy(row, &gp->rost[internal_location(gp, 0, y)], gp->width * sizeof(char));
|
memcpy(row, &gp->locations[internal_location(gp, 0, y)], gp->width * sizeof(char));
|
||||||
row[gp->width] = '\0';
|
row[gp->width] = '\0';
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@@ -251,11 +259,11 @@ char *grid_fetch_row(const grid *gp, const int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
grid *grid_copy(const grid *gp) {
|
grid *grid_copy(const grid *gp) {
|
||||||
if (gp != NULL && gp->rost != NULL) {
|
if (gp != NULL && gp->locations != NULL) {
|
||||||
const size_t grid_memory = ((gp->width + 1) * gp->height + 1) * sizeof(char);
|
const size_t grid_memory = ((gp->width + 1) * gp->height + 1) * sizeof(char);
|
||||||
|
|
||||||
char *rost = malloc(grid_memory);
|
char *locations = malloc(grid_memory);
|
||||||
if (rost == NULL) {
|
if (locations == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,18 +272,18 @@ grid *grid_copy(const grid *gp) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(rost, gp->rost, grid_memory);
|
memcpy(locations, gp->locations, grid_memory);
|
||||||
|
|
||||||
memcpy(new_grid, gp, sizeof(*gp));
|
memcpy(new_grid, gp, sizeof(*gp));
|
||||||
|
|
||||||
new_grid->rost = rost;
|
new_grid->locations = locations;
|
||||||
return new_grid;
|
return new_grid;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void grid_find(const grid *gp, const char c, int *x, int *y) {
|
void grid_find(const grid *gp, const char c, int *x, int *y) {
|
||||||
if (gp == NULL || gp->rost == NULL) {
|
if (gp == NULL || gp->locations == NULL) {
|
||||||
*x = -1;
|
*x = -1;
|
||||||
*y = -1;
|
*y = -1;
|
||||||
return;
|
return;
|
||||||
@@ -283,9 +291,9 @@ void grid_find(const grid *gp, const char c, int *x, int *y) {
|
|||||||
|
|
||||||
const char search[2] = {c};
|
const char search[2] = {c};
|
||||||
|
|
||||||
const int char_index = (int)strcspn(gp->rost, search);
|
const int char_index = (int)strcspn(gp->locations, search);
|
||||||
|
|
||||||
if (gp->rost[char_index] == '\0')
|
if (gp->locations[char_index] == '\0')
|
||||||
{
|
{
|
||||||
*x = -1;
|
*x = -1;
|
||||||
*y = -1;
|
*y = -1;
|
||||||
|
|||||||
2
grid.h
2
grid.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* grid.h
|
* Created by snapshot112 on 2/10/2025
|
||||||
*
|
*
|
||||||
* This module provides a grid api.
|
* This module provides a grid api.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 8/10/2025
|
||||||
*
|
|
||||||
* A game engine that can run and display games in square grids.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "grid_game_engine.h"
|
#include "grid_game_engine.h"
|
||||||
@@ -84,14 +82,13 @@ static void display_hackerman(const coordinate location) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void graceful_exit(const coordinate message_location) {
|
void graceful_exit(const coordinate message_location) {
|
||||||
mvaddstr(message_location.y, message_location.x, "Press ENTER or SPACE to exit.");
|
mvaddstr(message_location.y, message_location.x, "Press ENTER to exit.");
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (getch()) {
|
switch (getch()) {
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
||||||
case KEY_ENTER:
|
case KEY_ENTER:
|
||||||
case '\n':
|
case '\n':
|
||||||
case ' ':
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 15/10/2025.
|
||||||
*
|
*
|
||||||
* A game engine that uses the can run and display games in rectangular grids.
|
* A game engine build on top of a grid api to run and display games using ncurses.
|
||||||
* The graphics are made using ncurses.
|
|
||||||
*
|
*
|
||||||
* Please make sure to initialize the game engine before running any games.
|
* Please make sure to initialize the game engine before running any games.
|
||||||
*/
|
*/
|
||||||
@@ -133,12 +132,12 @@ void update_grid(grid *gp, char c, int x, int y);
|
|||||||
void game_exit_message(const grid *gp, coordinate location);
|
void game_exit_message(const grid *gp, coordinate location);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Waits for you to press ENTER or SPACE before exiting the game.
|
* Waits for you to press ENTER before exiting the game.
|
||||||
*
|
*
|
||||||
* Input:
|
* Input:
|
||||||
* coordinate: The location to show the message.
|
* coordinate: The location to show the message.
|
||||||
*
|
*
|
||||||
* Side effect: Prints "Press ENTER or SPACE to exit." game to the console.
|
* Side effect: Prints "Press ENTER to exit." game to the console.
|
||||||
*/
|
*/
|
||||||
void graceful_exit(coordinate message_location);
|
void graceful_exit(coordinate message_location);
|
||||||
|
|
||||||
|
|||||||
9
manual.c
9
manual.c
@@ -1,6 +1,7 @@
|
|||||||
//
|
/*
|
||||||
// Created by snapshot112 on 10/17/25.
|
* Created by snapshot112 on 10/17/2025
|
||||||
//
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "manual.h"
|
#include "manual.h"
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ void manual(const coordinate display_location) {
|
|||||||
|
|
||||||
// Wait until ESCAPE or BACKSPACE is pressed.
|
// Wait until ESCAPE or BACKSPACE is pressed.
|
||||||
timeout(200);
|
timeout(200);
|
||||||
for (int ch = getch(); ch != KEY_ESCAPE && ch != KEY_BACKSPACE && ch != ' '; ch = getch()) {
|
for (int ch = getch(); ch != KEY_ESCAPE && ch != KEY_BACKSPACE; ch = getch()) {
|
||||||
// Update the screen in the meantime to accommodate windows resizes.
|
// Update the screen in the meantime to accommodate windows resizes.
|
||||||
show_grid_on_offset(grid, display_location.x, display_location.y);
|
show_grid_on_offset(grid, display_location.x, display_location.y);
|
||||||
}
|
}
|
||||||
|
|||||||
8
manual.h
8
manual.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 10/17/2025
|
||||||
*
|
*
|
||||||
* Display the manual for the minigames
|
* Provides a way to display the minigame manual in the assets in game.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MINIGAME_MENU_MANUAL_H
|
#ifndef MINIGAME_MENU_MANUAL_H
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "grid_game_engine.h"
|
#include "grid_game_engine.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A game manual for the minigames menu.
|
* An in game manual for the minigames menu.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before opening the manual
|
* Please make sure to include and initialize the game engine before opening the manual
|
||||||
*
|
*
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
* Clears the console and uses it to display the manual.
|
* Clears the console and uses it to display the manual.
|
||||||
*
|
*
|
||||||
* Controls:
|
* Controls:
|
||||||
* Press ESCAPE or ENTER to exit the manual.
|
* Press ESCAPE or BACKSPACE to exit the manual.
|
||||||
*/
|
*/
|
||||||
void manual(coordinate display_location);
|
void manual(coordinate display_location);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
/*
|
||||||
// Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 6/10/2025
|
||||||
//
|
*/
|
||||||
|
|
||||||
#include "maze_runner.h"
|
#include "maze_runner.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
|
* Created by snapshot112 on 6/10/2025
|
||||||
|
*
|
||||||
* Naam: Jeroen Boxhoorn
|
* Naam: Jeroen Boxhoorn
|
||||||
* UvAnetID: 16333969
|
* UvAnetID: 16333969
|
||||||
* Studie: BSc Informatica
|
* Studie: BSC Informatica
|
||||||
*
|
*
|
||||||
* A game of maze runner configured to run on the grid game engine.
|
* A game of maze runner build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling maze_runner();
|
* Please make sure to include and initialize the game engine before calling maze_runner();
|
||||||
*
|
*
|
||||||
@@ -23,7 +25,7 @@
|
|||||||
#define MINIGAME_MENU_MAZE_RUNNER_H
|
#define MINIGAME_MENU_MAZE_RUNNER_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A game of maze runner configured to run on the grid game engine.
|
* A game of maze runner build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling maze_runner();
|
* Please make sure to include and initialize the game engine before calling maze_runner();
|
||||||
*
|
*
|
||||||
@@ -32,7 +34,7 @@
|
|||||||
*
|
*
|
||||||
* Controls:
|
* Controls:
|
||||||
* use WSAD or arrow keys to move through the maze.
|
* use WSAD or arrow keys to move through the maze.
|
||||||
* Use BACKSPACE to exit the game early.
|
* Use BACKSPACE or ESCAPE to exit the game early.
|
||||||
*/
|
*/
|
||||||
void maze_runner(void);
|
void maze_runner(void);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
/*
|
||||||
// Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 15/10/2025
|
||||||
//
|
*/
|
||||||
|
|
||||||
#include "minesweeper.h"
|
#include "minesweeper.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 15/10/2025
|
||||||
*
|
*
|
||||||
* A game of minesweeper runner configured to run on the grid game engine.
|
* A game of minesweeper build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling snake();
|
* Please make sure to include and initialize the game engine before calling minesweeper();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MINIGAME_MENU_MINESWEEPER_H
|
#ifndef MINIGAME_MENU_MINESWEEPER_H
|
||||||
#define MINIGAME_MENU_MINESWEEPER_H
|
#define MINIGAME_MENU_MINESWEEPER_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A game of minesweeper configured to run on the grid game engine.
|
* A game of minesweeper build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling snake();
|
* Please make sure to include and initialize the game engine before calling minesweeper();
|
||||||
*
|
*
|
||||||
* Side Effects:
|
* Side Effects:
|
||||||
* Clears the console and uses it to play a game of minesweeper.
|
* Clears the console and uses it to play a game of minesweeper.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
/*
|
||||||
// Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 15/10/2025
|
||||||
//
|
*/
|
||||||
|
|
||||||
#include "minigame_menu.h"
|
#include "minigame_menu.h"
|
||||||
|
|
||||||
@@ -152,7 +152,6 @@ static int navigate_menu(void) {
|
|||||||
}
|
}
|
||||||
launch_game(SELECTED_GAME);
|
launch_game(SELECTED_GAME);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 15/10/2025
|
||||||
*
|
*
|
||||||
* A minigame menu for games configured to run on the grid game engine.
|
* A minigame menu for games build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling menu();
|
* Please make sure to include and initialize the game engine before calling menu();
|
||||||
*/
|
*/
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#define MINIGAME_MENU_MINIGAME_MENU_H
|
#define MINIGAME_MENU_MINIGAME_MENU_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A minigame menu for games configured to run on the grid game engine.
|
* A minigame menu for games build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling menu();
|
* Please make sure to include and initialize the game engine before calling menu();
|
||||||
*
|
*
|
||||||
@@ -18,10 +18,10 @@
|
|||||||
* Clears the console and uses it to display a minigame menu.
|
* Clears the console and uses it to display a minigame menu.
|
||||||
*
|
*
|
||||||
* Controls:
|
* Controls:
|
||||||
* 'w'/'arr_up: Next menu item.
|
* 'w'/'arr_up': Next menu item.
|
||||||
* 's'/'arr_down': Previous menu item.
|
* 's'/'arr_down': Previous menu item.
|
||||||
* 'f': Select current menu item.
|
* 'f'/'ENTER': Select current menu item.
|
||||||
* 'BACKSPACE': Exit the menu.
|
* 'BACKSPACE'/'ESC': Exit the menu.
|
||||||
*/
|
*/
|
||||||
void minigame_menu(void);
|
void minigame_menu(void);
|
||||||
|
|
||||||
|
|||||||
6
snake.c
6
snake.c
@@ -1,6 +1,6 @@
|
|||||||
//
|
/*
|
||||||
// Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 15/10/2025
|
||||||
//
|
*/
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 199309
|
#define _POSIX_C_SOURCE 199309
|
||||||
|
|
||||||
|
|||||||
8
snake.h
8
snake.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Created by snapshot112 on 10/15/25.
|
* Created by snapshot112 on 15/10/2025
|
||||||
*
|
*
|
||||||
* A game of maze runner configured to run on the grid game engine.
|
* A game of maze runner build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling snake();
|
* Please make sure to include and initialize the game engine before calling snake();
|
||||||
*/
|
*/
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#define MINIGAME_MENU_SNAKE_H
|
#define MINIGAME_MENU_SNAKE_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A game of snake configured to run on the grid game engine.
|
* A game of snake build on the grid game engine.
|
||||||
*
|
*
|
||||||
* Please make sure to include and initialize the game engine before calling snake();
|
* Please make sure to include and initialize the game engine before calling snake();
|
||||||
*
|
*
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
* Controls:
|
* Controls:
|
||||||
* Use WSAD or arrow keys to redirect the snake.
|
* Use WSAD or arrow keys to redirect the snake.
|
||||||
* Use BACKSPACE to exit the game early.
|
* Use BACKSPACE or ESCAPE to exit the game early.
|
||||||
*/
|
*/
|
||||||
void snake(void);
|
void snake(void);
|
||||||
|
|
||||||
|
|||||||
6
spel.c
6
spel.c
@@ -1,7 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
|
* Created by snapshot112 on 15/10/2025
|
||||||
|
*
|
||||||
* Naam: Jeroen Boxhoorn
|
* Naam: Jeroen Boxhoorn
|
||||||
* UvAnetID: 16333969
|
* UvAnetID: 16333969
|
||||||
* Studie: BSc Informatica
|
* Studie: BSC Informatica
|
||||||
*
|
*
|
||||||
* A minigame menu that lets you play games on the grid game engine.
|
* A minigame menu that lets you play games on the grid game engine.
|
||||||
*
|
*
|
||||||
@@ -9,6 +11,8 @@
|
|||||||
* - maze runner
|
* - maze runner
|
||||||
* - snake
|
* - snake
|
||||||
* - minesweeper
|
* - minesweeper
|
||||||
|
*
|
||||||
|
* A user manual can be found in the assets or by selected it in the menu using ENTER or 'f'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "grid_game_engine.h"
|
#include "grid_game_engine.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user