49 lines
1.4 KiB
C
49 lines
1.4 KiB
C
#ifndef TWN_CONTEXT_H
|
|
#define TWN_CONTEXT_H
|
|
|
|
#include "twn_types.h"
|
|
#include "twn_engine_api.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
|
|
/* context that is only valid for current frame */
|
|
/* any changes to it will be dropped, unless explicitly stated */
|
|
typedef struct Context {
|
|
/* you may read from and write to this one from game code */
|
|
/* it is ensured to persist between initializations */
|
|
void *udata;
|
|
|
|
/* which frame is it, starting from 0 at startup */
|
|
uint64_t frame_number;
|
|
|
|
/* real time spent on one frame (in seconds) */
|
|
/* townengine is fixed step based, so you don't have */
|
|
/* TODO: actually set it */
|
|
float frame_duration;
|
|
|
|
/* resolution is set from config and dictates both logical and drawing space, as they're related */
|
|
/* even if scaling is done, game logic should never change over that */
|
|
Vec2i resolution;
|
|
Vec2i mouse_position;
|
|
Vec2i mouse_movement;
|
|
|
|
/* is set on startup, should be used as source of randomness */
|
|
uint64_t random_seed;
|
|
|
|
/* whether debugging logic should be enabled in user code */
|
|
bool debug;
|
|
|
|
/* is set to true when state is invalidated and needs to be rebuilt */
|
|
/* watch for it and handle properly! */
|
|
bool initialization_needed;
|
|
} Context;
|
|
|
|
/* when included after twn_engine_context there's an 'ctx' defined already */
|
|
#ifndef TWN_ENGINE_CONTEXT_C_H
|
|
TWN_API extern Context ctx;
|
|
#endif
|
|
|
|
#endif
|