thrive/01_text_adventure/main.c

58 lines
1.4 KiB
C
Raw Normal View History

2025-01-02 20:57:00 -05:00
#include "game.h"
2024-08-28 17:27:35 -04:00
#include "../raylib.h"
2024-08-30 06:27:14 -04:00
#include "log.h"
2024-08-28 17:27:35 -04:00
#include "input.h"
2025-01-12 20:15:25 -05:00
#include "parse.h"
2024-08-28 17:27:35 -04:00
#include <stdlib.h>
2025-01-04 04:45:44 -05:00
#include <stdio.h>
2025-01-02 20:57:00 -05:00
#include <stdbool.h>
2024-08-28 17:27:35 -04:00
#define TARGET_FPS 60
2025-01-03 20:59:10 -05:00
int main(void) {
2024-08-28 17:27:35 -04:00
InitWindow(800, 450, "Text Adventure");
SetTargetFPS(TARGET_FPS);
2025-01-04 04:45:44 -05:00
Game *g = game_create();
game_load_rooms(g);
g->current_room = &g->rooms->rooms[0];
2025-01-07 20:31:03 -05:00
game_load_transitions(g);
2025-01-12 19:50:11 -05:00
game_load_words(g);
2025-01-13 19:37:38 -05:00
game_load_flags(g);
2025-01-16 20:15:50 -05:00
game_load_actions(g);
for (int i = 0; i < g->actions->count; i++) {
for (int j = 0; j < g->actions->actions[i].words_count; j++) {
printf("%s ", g->actions->actions[i].words[j]->word);
}
2025-01-18 06:34:36 -05:00
printf("|");
for (int j = 0; j < g->actions->actions[i].predicates_count; j++) {
if (j > 0) printf(" & ");
print_predicate(g->actions->actions[i].predicates[j]);
}
2025-01-18 19:34:45 -05:00
printf("|%d|%s|", g->actions->actions[i].priority, g->actions->actions[i].description);
for (int j = 0; j < g->actions->actions[i].effects_count; j++) {
if (j > 0) printf(" & ");
print_effect(g->actions->actions[i].effects[j]);
}
2025-01-16 20:15:50 -05:00
printf("\n");
}
2025-01-13 19:37:38 -05:00
2025-01-18 19:34:45 -05:00
printf("before action\n");
printf("lever_pulled: %d\n", flag_value(g->flags, "LEVER_PULLED"));
cause_effect(g, g->actions->actions[2].effects[0]);
printf("after action\n");
printf("lever_pulled: %d\n", flag_value(g->flags, "LEVER_PULLED"));
game_run_until_close(g);
2024-08-28 17:27:35 -04:00
CloseWindow();
free_game(g);
2024-08-28 17:27:35 -04:00
return 0;
}