Got the minigame menu up, running and documented. Also split up the game file
This commit is contained in:
103
grid_game_engine.h
Normal file
103
grid_game_engine.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Created by snapshot112 on 10/15/25.
|
||||
*
|
||||
* A game engine that uses the can run and display games in rectangular grids.
|
||||
* The graphics are made using ncursesw.
|
||||
*
|
||||
* Please make sure to initialize the game engine before running any games.
|
||||
*/
|
||||
|
||||
#ifndef MINIGAME_MENU_GRID_GAME_ENGINE_H
|
||||
#define MINIGAME_MENU_GRID_GAME_ENGINE_H
|
||||
#include "rooster.h"
|
||||
|
||||
typedef enum {
|
||||
BLACK = 1,
|
||||
WHITE = 2,
|
||||
BLUE = 3,
|
||||
GREEN = 4,
|
||||
CYAN = 5,
|
||||
MAGENTA = 6,
|
||||
YELLOW = 7,
|
||||
RED = 8
|
||||
} game_colors;
|
||||
|
||||
typedef struct {
|
||||
char name[100];
|
||||
rooster *game_map;
|
||||
} game_maps;
|
||||
|
||||
/*
|
||||
* A proper modulo function.
|
||||
* The one provided by c: '%' doesn't work according to the mathematical definition.
|
||||
*/
|
||||
int modulo(int number, int mod);
|
||||
|
||||
/*
|
||||
* Displays the given grid with the given offset using ncurses.
|
||||
*
|
||||
* Input:
|
||||
* gp: A pointer to the grid.
|
||||
*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* Displays the given grid with ncurses.
|
||||
*
|
||||
* Input:
|
||||
* gp: A pointer to the grid.
|
||||
*
|
||||
* Side effect:
|
||||
* The console is cleared and the grid is printed.
|
||||
*/
|
||||
void show_grid(const rooster *gp);
|
||||
|
||||
/*
|
||||
* Updates a single location in the grid.
|
||||
*
|
||||
* Input:
|
||||
* gp: A pointer to the grid.
|
||||
* c: The character to update the location with.
|
||||
* x: The x-coordinate of the spot you want to update.
|
||||
* y: The y-coordinate of the spot you want to update.
|
||||
*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* Display the ending screen that matches the end state of the grid.
|
||||
*
|
||||
* Input:
|
||||
* gp: A pointer to the grid.
|
||||
*
|
||||
* Side Effects:
|
||||
* The end of game screen gets displayed with a graceful exit.
|
||||
*/
|
||||
void game_exit_screen(rooster *gp);
|
||||
|
||||
/*
|
||||
* Waits for you to press 'q' before exiting the game.
|
||||
*
|
||||
* Side effect: Prints "Press 'q' to exit." game to the console.
|
||||
*/
|
||||
void graceful_exit(void);
|
||||
|
||||
/*
|
||||
* Initialize ncurses.
|
||||
*
|
||||
* This enables cbreak, noecho, hides the cursor and enables the extra keys.
|
||||
* This also creates the color pairs needed for game_colors,
|
||||
*/
|
||||
void init_engine(void);
|
||||
|
||||
/*
|
||||
* Cleanup ncurses.
|
||||
*/
|
||||
void cleanup_engine(void);
|
||||
|
||||
#endif //MINIGAME_MENU_GRID_GAME_ENGINE_H
|
||||
Reference in New Issue
Block a user