create /apps/temapltes/ structure, clean up cmake files to use directory name for binary name directly
This commit is contained in:
27
apps/templates/c/game.c
Normal file
27
apps/templates/c/game.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "twn_game_api.h"
|
||||
#include "state.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
void game_tick(void) {
|
||||
/* do state initialization when engine asks for it */
|
||||
/* it could happen multiple times per application run, as game code is reloadable */
|
||||
if (ctx.initialization_needed) {
|
||||
/* application data could be stored in ctx.udata and retrieved anywhere */
|
||||
if (!ctx.udata)
|
||||
ctx.udata = calloc(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);
|
||||
}
|
||||
Reference in New Issue
Block a user