27 lines
613 B
C
27 lines
613 B
C
|
#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);
|
||
|
}
|