Add in engine configuration

All engine constants now sits in a single header file for easy tweaking
Also, SFX list fields is now an array rather than a pointer instead.
scene_man
En Yi 2023-10-13 21:55:30 +08:00
parent b9b0c11524
commit 7dc66945da
9 changed files with 30 additions and 28 deletions

View File

@ -6,9 +6,8 @@
#include "sc/map/sc_map.h"
#include "sc/queue/sc_queue.h"
#define N_TAGS 10
#define N_COMPONENTS 14
#define MAX_COMP_POOL_SIZE 1024
#include "engine_conf.h"
typedef struct EntityManager EntityManager_t;
typedef struct Entity Entity_t;

View File

@ -1,5 +1,6 @@
#include "assets.h"
#include "assert.h"
#include "engine_conf.h"
#define RRES_RAYLIB_IMPLEMENTATION
#include "rres.h"
@ -7,13 +8,6 @@
#include "zstd.h"
#include <stdio.h>
#define MAX_TEXTURES 16
#define MAX_SPRITES 64
#define MAX_SOUNDS 16
#define MAX_FONTS 4
#define MAX_N_TILES 4096
#define MAX_NAME_LEN 32
#define MAX_LEVEL_PACK 4
uint8_t n_loaded[5] = {0};
// Hard limit number of

View File

@ -1,7 +1,6 @@
#ifndef __COLLISION_FUNCS_H
#define __COLLISION_FUNCS_H
#include "EC.h"
#define MAX_TILE_TYPES 16
typedef enum SolidType
{

View File

@ -4,6 +4,7 @@
void init_engine(GameEngine_t* engine)
{
sc_queue_init(&engine->key_buffer);
engine->sfx_list.n_sfx = N_SFX;
memset(engine->sfx_list.sfx, 0, engine->sfx_list.n_sfx * sizeof(SFX_t));
init_memory_pools();
init_assets(&engine->assets);

View File

@ -9,8 +9,8 @@ typedef struct Scene Scene_t;
typedef struct SFXList
{
SFX_t* sfx;
uint32_t* sfx_queue;
SFX_t sfx[N_SFX];
uint32_t sfx_queue[N_SFX];
uint32_t n_sfx;
uint32_t played_sfx;
} SFXList_t;

View File

@ -0,0 +1,18 @@
#ifndef _ENGINE_CONF_H
#define _ENGINE_CONF_H
#define MAX_TEXTURES 16
#define MAX_SPRITES 64
#define MAX_SOUNDS 16
#define MAX_FONTS 4
#define MAX_N_TILES 4096
#define MAX_NAME_LEN 32
#define MAX_LEVEL_PACK 4
#define N_SFX 18
#define MAX_TILE_TYPES 16
#define N_TAGS 10
#define N_COMPONENTS 14
#define MAX_COMP_POOL_SIZE 1024
#endif // _ENGINE_CONF_H

View File

@ -188,21 +188,21 @@ const char** GetTextLines(const char* text, int* count)
int textSize = (int)strlen(text);
lines[0] = text;
int len = 0;
//int len = 0;
*count = 1;
int lineSize = 0; // Stores current line size, not returned
//int lineSize = 0; // Stores current line size, not returned
for (int i = 0, k = 0; (i < textSize) && (*count < RAYGUI_MAX_TEXT_LINES); i++)
{
if (text[i] == '\n')
{
lineSize = len;
//lineSize = len;
k++;
lines[k] = &text[i + 1]; // WARNING: next value is valid?
len = 0;
//len = 0;
*count += 1;
}
else len++;
//else len++;
}
//lines[*count - 1].size = len;

View File

@ -7,9 +7,6 @@
#include <emscripten/emscripten.h>
#endif
static SFX_t sfx_buffer[N_SFX] = {0};
static uint32_t sfx_counts[N_SFX] = {0};
Scene_t* scenes[1];
static GameEngine_t engine =
{
@ -17,12 +14,7 @@ static GameEngine_t engine =
.max_scenes = 1,
.curr_scene = 0,
.assets = {0},
.sfx_list = {
.sfx = sfx_buffer,
.n_sfx = N_SFX,
.sfx_queue = sfx_counts,
.played_sfx = 0,
}
.sfx_list = {0}
};
void update_loop(void)

View File

@ -12,7 +12,6 @@ typedef enum EntityTag {
DYNMEM_ENT_TAG,
} EntityTag_t;
#define N_SFX 18
typedef enum SFXTag {
PLAYER_JMP_SFX = 0,
PLAYER_LAND_SFX,