Tweak scene render function
Delegate BeginDrawing and EndDrawing to individual scenesscene_man
parent
41e4b34869
commit
0d4089d9ce
|
@ -143,7 +143,7 @@ void update_sfx_list(GameEngine_t* engine)
|
|||
}
|
||||
|
||||
//void init_scene(Scene_t* scene, SceneType_t scene_type, system_func_t render_func, action_func_t action_func)
|
||||
void init_scene(Scene_t* scene, system_func_t render_func, action_func_t action_func)
|
||||
void init_scene(Scene_t* scene, render_func_t render_func, action_func_t action_func)
|
||||
{
|
||||
sc_map_init_64(&scene->action_map, 32, 0);
|
||||
sc_array_init(&scene->systems);
|
||||
|
@ -178,9 +178,10 @@ inline void update_scene(Scene_t* scene, float delta_time)
|
|||
|
||||
inline void render_scene(Scene_t* scene)
|
||||
{
|
||||
BeginDrawing();
|
||||
scene->render_function(scene);
|
||||
EndDrawing();
|
||||
if (scene->render_function != NULL)
|
||||
{
|
||||
scene->render_function(scene);
|
||||
}
|
||||
}
|
||||
|
||||
inline void do_action(Scene_t* scene, ActionType_t action, bool pressed)
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef enum SceneState {
|
|||
SCENE_ENDED,
|
||||
}SceneState_t;
|
||||
|
||||
typedef void(*render_func_t)(Scene_t*);
|
||||
typedef void(*system_func_t)(Scene_t*);
|
||||
typedef void(*action_func_t)(Scene_t*, ActionType_t, bool);
|
||||
sc_array_def(system_func_t, systems);
|
||||
|
@ -44,7 +45,7 @@ sc_array_def(system_func_t, systems);
|
|||
struct Scene {
|
||||
struct sc_map_64 action_map; // key -> actions
|
||||
struct sc_array_systems systems;
|
||||
system_func_t render_function;
|
||||
render_func_t render_function;
|
||||
action_func_t action_function;
|
||||
EntityManager_t ent_manager;
|
||||
float delta_time;
|
||||
|
@ -72,7 +73,7 @@ extern void render_scene(Scene_t* scene);
|
|||
extern void do_action(Scene_t* scene, ActionType_t action, bool pressed);
|
||||
|
||||
//void init_scene(Scene_t* scene, SceneType_t scene_type, system_func_t render_func, action_func_t action_func);
|
||||
void init_scene(Scene_t* scene, system_func_t render_func, action_func_t action_func);
|
||||
void init_scene(Scene_t* scene, render_func_t render_func, action_func_t action_func);
|
||||
void free_scene(Scene_t* scene);
|
||||
|
||||
#endif // __ENGINE_H
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _ENGINE_CONF_H
|
||||
#define _ENGINE_CONF_H
|
||||
|
||||
#define MAX_ENTITIES 2048
|
||||
#define MAX_TEXTURES 16
|
||||
#define MAX_SPRITES 64
|
||||
#define MAX_SOUNDS 32
|
||||
|
@ -11,12 +12,12 @@
|
|||
#define N_SFX 32
|
||||
#define MAX_EMITTER_CONF 8
|
||||
//#define MAX_PARTICLE_EMITTER 8
|
||||
#define MAX_ACTIVE_PARTICLE_EMITTER 128
|
||||
#define MAX_PARTICLES 32
|
||||
#define MAX_ACTIVE_PARTICLE_EMITTER 512
|
||||
#define MAX_PARTICLES 64
|
||||
|
||||
#define MAX_TILE_TYPES 16
|
||||
|
||||
#define N_TAGS 10
|
||||
#define N_COMPONENTS 15
|
||||
#define MAX_COMP_POOL_SIZE 4096
|
||||
#define N_COMPONENTS 20
|
||||
#define MAX_COMP_POOL_SIZE MAX_ENTITIES
|
||||
#endif // _ENGINE_CONF_H
|
||||
|
|
|
@ -92,6 +92,7 @@ static void level_scene_render_func(Scene_t* scene)
|
|||
draw_rec.y = 0;
|
||||
draw_rec.height *= -1;
|
||||
static char buffer[512];
|
||||
BeginDrawing();
|
||||
ClearBackground(LIGHTGRAY);
|
||||
DrawTextureRec(
|
||||
data->game_viewport.texture,
|
||||
|
@ -187,6 +188,7 @@ static void level_scene_render_func(Scene_t* scene)
|
|||
gui_y += 300;
|
||||
sprintf(buffer, "Chests: %u / %u", data->coins.current, data->coins.total);
|
||||
DrawText(buffer, gui_x, gui_y, 24, BLACK);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
static void render_editor_game_scene(Scene_t* scene)
|
||||
|
|
|
@ -20,6 +20,7 @@ static void level_scene_render_func(Scene_t* scene)
|
|||
draw_rec.height *= -1;
|
||||
|
||||
static char buffer[512];
|
||||
BeginDrawing();
|
||||
ClearBackground(LIGHTGRAY);
|
||||
DrawTextureRec(
|
||||
data->game_viewport.texture,
|
||||
|
@ -50,6 +51,7 @@ static void level_scene_render_func(Scene_t* scene)
|
|||
|
||||
print_mempool_stats(buffer);
|
||||
DrawText(buffer, gui_x, 350, 12, BLACK);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed)
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
static void menu_scene_render_func(Scene_t* scene)
|
||||
{
|
||||
MenuSceneData_t* data = &(CONTAINER_OF(scene, MenuScene_t, scene)->data);
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("This is a game", 25, 220, 12, BLACK);
|
||||
UI_button(data->buttons, "Start");
|
||||
UI_button(data->buttons + 1, "Sandbox");
|
||||
UI_button(data->buttons + 2, "Continue");
|
||||
UI_button(data->buttons + 3, "Exit");
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("This is a game", 25, 220, 12, BLACK);
|
||||
UI_button(data->buttons, "Start");
|
||||
UI_button(data->buttons + 1, "Sandbox");
|
||||
UI_button(data->buttons + 2, "Continue");
|
||||
UI_button(data->buttons + 3, "Exit");
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
static void exec_component_function(Scene_t* scene, int sel)
|
||||
|
|
Loading…
Reference in New Issue