implement game configuration file
this integrates https://github.com/cktan/tomlc99 into the repo as a dependency
This commit is contained in:
@ -1,35 +1,25 @@
|
||||
#ifndef TWN_CONFIG_H
|
||||
#define TWN_CONFIG_H
|
||||
|
||||
/*
|
||||
* this file is for configuration values which are to be set at
|
||||
* compile time. generally speaking, it's for things that would be unwise to
|
||||
* change mid-development without considering the work it might take to
|
||||
* adapt the game logic.
|
||||
*
|
||||
* if you're looking for distribution-related definitions like
|
||||
* APP_NAME, you should know that they are set from CMake.
|
||||
*/
|
||||
/* TODO: consider if it's still necessary to keep these in one place */
|
||||
|
||||
|
||||
#define TICKS_PER_SECOND 60
|
||||
#define FIXED_DELTA_TIME (1.0 / TICKS_PER_SECOND)
|
||||
#define TICKS_PER_SECOND_DEFAULT 60
|
||||
|
||||
#define RENDER_BASE_WIDTH 640
|
||||
#define RENDER_BASE_HEIGHT 360
|
||||
#define RENDER_BASE_RATIO ((float)RENDER_BASE_WIDTH / (float)RENDER_BASE_HEIGHT)
|
||||
#define BASE_RENDER_WIDTH_DEFAULT 640
|
||||
#define BASE_RENDER_HEIGHT_DEFAULT 360
|
||||
|
||||
#define TEXTURE_ATLAS_SIZE 2048
|
||||
#define TEXTURE_ATLAS_SIZE_DEFAULT 2048
|
||||
#define TEXTURE_ATLAS_BIT_DEPTH 32
|
||||
#define TEXTURE_ATLAS_FORMAT SDL_PIXELFORMAT_RGBA32
|
||||
|
||||
#define NUM_KEYBIND_SLOTS 8
|
||||
#define KEYBIND_SLOTS_DEFAULT 3
|
||||
|
||||
#define AUDIO_FREQUENCY 48000
|
||||
#define AUDIO_N_CHANNELS 2
|
||||
|
||||
#define TEXT_FONT_TEXTURE_SIZE 1024
|
||||
#define TEXT_FONT_OVERSAMPLING 4
|
||||
#define TEXT_FONT_FILTERING TEXTURE_FILTER_LINEAR
|
||||
#define TEXT_FONT_TEXTURE_SIZE_DEFAULT 2048
|
||||
#define TEXT_FONT_OVERSAMPLING_DEFAULT 4
|
||||
#define TEXT_FONT_FILTERING_DEFAULT TEXTURE_FILTER_LINEAR
|
||||
|
||||
#endif
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
typedef struct Context {
|
||||
struct InputState input;
|
||||
InputState input;
|
||||
|
||||
int64_t delta_time; /* preserves real time frame delta with no manipilation */
|
||||
uint64_t tick_count;
|
||||
@ -17,12 +17,14 @@ typedef struct Context {
|
||||
/* set just once on startup */
|
||||
uint64_t random_seed;
|
||||
|
||||
/* this should be a multiple of TICKS_PER_SECOND */
|
||||
/* this should be a multiple of the current ticks per second */
|
||||
/* use it to simulate low framerate (e.g. at 60 tps, set to 2 for 30 fps) */
|
||||
/* it can be changed at runtime; any resulting logic anomalies are bugs */
|
||||
unsigned int update_multiplicity;
|
||||
int window_w;
|
||||
int window_h;
|
||||
int base_draw_w;
|
||||
int base_draw_h;
|
||||
|
||||
/* you may read from and write to these from game code */
|
||||
void *udata;
|
||||
|
@ -41,9 +41,9 @@ typedef struct Button {
|
||||
typedef struct Action {
|
||||
size_t num_bindings;
|
||||
|
||||
/* if you bind more than NUM_KEYBIND_SLOTS (set in config.h) */
|
||||
/* if you bind more than the number set in the configuration file */
|
||||
/* it forgets the first Button to add the new one at the end */
|
||||
Button bindings[NUM_KEYBIND_SLOTS];
|
||||
Button *bindings;
|
||||
|
||||
Vec2 position; /* set if applicable, e.g. mouse click */
|
||||
bool is_pressed;
|
||||
|
Reference in New Issue
Block a user