forked from snapshot112/minigame-menu
wip
This commit is contained in:
42
spel.c
42
spel.c
@@ -30,6 +30,22 @@
|
||||
|
||||
#include "rooster.h"
|
||||
|
||||
typedef struct {
|
||||
char name[100];
|
||||
rooster *game_map;
|
||||
} game_maps;
|
||||
|
||||
void toon_rooster_op_locatie(rooster *rp, int starting_x, int starting_y) {
|
||||
int height = rooster_hoogte(rp);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
char *rij = rooster_vraag_rij(rp, y);
|
||||
mvprintw(starting_y + y, starting_x, "%s", rij);
|
||||
free(rij);
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
/* Toont het gegeven rooster met ncurses.
|
||||
*
|
||||
* Input:
|
||||
@@ -41,18 +57,7 @@
|
||||
void toon_rooster(rooster *rp) {
|
||||
clear();
|
||||
|
||||
int height = rooster_hoogte(rp);
|
||||
int width = rooster_breedte(rp);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (rooster_bevat(rp, x, y) == 1)
|
||||
{
|
||||
mvaddch(y, x, rooster_kijk(rp, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
toon_rooster_op_locatie(rp, 0, 0);
|
||||
}
|
||||
|
||||
void update_grid(rooster *rp, char c, int x, int y) {
|
||||
@@ -211,17 +216,20 @@ void graceful_exit() {
|
||||
}
|
||||
}
|
||||
|
||||
void toon_menu(rooster *rp) {
|
||||
toon_rooster(rp);
|
||||
rooster_zet_toestand(rp, AAN_HET_SPELEN);
|
||||
run_maze(rp);
|
||||
maze_exit_screen(rp);
|
||||
graceful_exit();
|
||||
}
|
||||
|
||||
/*
|
||||
* Speelt het spel met een gegeven rooster tot de toestand niet langer
|
||||
* AAN_HET_SPELEN is.
|
||||
*/
|
||||
void speel(rooster *rp) {
|
||||
toon_rooster(rp);
|
||||
rooster_zet_toestand(rp, AAN_HET_SPELEN);
|
||||
run_maze(rp);
|
||||
maze_exit_screen(rp);
|
||||
graceful_exit();
|
||||
toon_menu(rp);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
Reference in New Issue
Block a user