General refactor and minor improvements

This commit is contained in:
2025-10-18 18:56:28 +02:00
parent 103f85d07e
commit 6b0e858064
13 changed files with 616 additions and 466 deletions

View File

@@ -9,7 +9,7 @@
#ifndef MINIGAME_MENU_GRID_GAME_ENGINE_H
#define MINIGAME_MENU_GRID_GAME_ENGINE_H
#include "rooster.h"
#include "grid.h"
#define KEY_ESCAPE 27
@@ -32,7 +32,7 @@ typedef enum {
typedef struct {
char name[100];
rooster *game_map;
grid *game_map;
} game_maps;
/*
@@ -63,7 +63,7 @@ int modulo(int number, int mod);
* Side effect:
* The console is cleared and the grid is printed.
*/
void show_grid_on_offset(const rooster *gp, int starting_x, int starting_y);
void show_grid_on_offset(const grid *gp, int starting_x, int starting_y);
/*
* Displays the given grid with ncurses.
@@ -74,7 +74,37 @@ void show_grid_on_offset(const rooster *gp, int starting_x, int starting_y);
* Side effect:
* The console is cleared and the grid is printed.
*/
void show_grid(const rooster *gp);
void show_grid(const grid *gp);
/*
* Turn on color highlighting for ncurses
*
* Input:
* color: The color you want the highlight to be.
*
* Side Effects:
* Enables color highlighting in ncurses.
*
* Note:
* This should always be disabled with disable_highlights before being called again.
* Not disabling the current highlight before enabling another one is undefined behaviour.
*/
void enable_highlight(game_colors color);
/*
* Turn off color highlighting for ncurses
*
* Input:
* color: The color highlighting you want to turn off.
*
* Side Effects:
* Enables color highlighting in ncurses.
*
* Note:
* This should always be enabled with enable_highlights before being called.
* Disabling the highlight before enabling it is undefined behaviour.
*/
void disable_highlight(game_colors color);
/*
* Updates a single location in the grid.
@@ -88,7 +118,7 @@ void show_grid(const rooster *gp);
* Side effect:
* The update gets applied both on the grid and on the screen.
*/
void update_grid(rooster *gp, char c, int x, int y);
void update_grid(grid *gp, char c, int x, int y);
/*
* Display the ending screen that matches the end state of the grid.
@@ -100,7 +130,7 @@ void update_grid(rooster *gp, char c, int x, int y);
* Side Effects:
* The end of game screen gets displayed with a graceful exit.
*/
void game_exit_screen(const rooster *gp, coordinate location);
void game_exit_message(const grid *gp, coordinate location);
/*
* Waits for you to press ENTER or SPACE before exiting the game.