townengine/apps/template/game.c

27 lines
613 B
C
Raw Normal View History

2024-07-29 22:20:30 +00:00
#include "townengine/game_api.h"
#include "game.h"
#include "state.h"
#include <malloc.h>
void game_tick(void) {
/* do your initialization on first tick */
if (ctx.tick_count == 0) {
/* application data could be stored in ctx.udata and retrieved anywhere */
ctx.udata = ccalloc(1, sizeof (struct state));
}
/* a lot of data is accessible from `ctx`, look into `townengine/context.h` for more */
struct state *state = ctx.udata;
++state->counter;
}
void game_end(void) {
/* do your deinitialization here */
struct state *state = ctx.udata;
free(state);
}