Outline for level loading
This commit is contained in:
parent
2a81321b7e
commit
5b00594685
12
app.c
12
app.c
@ -17,7 +17,7 @@
|
||||
App *app_NewApp() {
|
||||
render_LoadBundle("bundles.txt");
|
||||
|
||||
App *app = malloc(sizeof(App));
|
||||
App *app = zero_malloc(sizeof(App));
|
||||
|
||||
app->input = input_NewSystem(app);
|
||||
app->physics = physics_NewSystem(app);
|
||||
@ -26,7 +26,8 @@ App *app_NewApp() {
|
||||
app->camera = camera_NewSystem(app);
|
||||
app->particle = particle_NewSystem(app);
|
||||
|
||||
app->wantQuit = false;
|
||||
app->switch_level = NULL;
|
||||
app->wantQuit = false;
|
||||
|
||||
|
||||
Entity *player = entity_Create(app->entity, "player");
|
||||
@ -104,6 +105,13 @@ void app_DeleteApp(App *app) {
|
||||
|
||||
|
||||
void app_Advance(App *app, Duration deltaTime) {
|
||||
// Limit deltaTime to 20ms (1/50 second)
|
||||
if (deltaTime.microseconds > 20000)
|
||||
deltaTime.microseconds = 20000;
|
||||
|
||||
if (app->switch_level != NULL)
|
||||
_app_SwitchLevel(app);
|
||||
|
||||
particle_Advance(app->particle, deltaTime);
|
||||
input_Advance(app->input);
|
||||
player_Advance(app->player, deltaTime);
|
||||
|
7
app.h
7
app.h
@ -22,7 +22,8 @@ typedef struct _App {
|
||||
System_Camera *camera;
|
||||
System_Particle *particle;
|
||||
|
||||
bool wantQuit;
|
||||
char *switch_level;
|
||||
bool wantQuit;
|
||||
} App;
|
||||
|
||||
App *app_NewApp();
|
||||
@ -33,6 +34,10 @@ void app_Render(App *app);
|
||||
|
||||
void app_DebugText(App *app, vector_Vector *vec_string);
|
||||
|
||||
// Trigger the app to reload all entities before next frame update.
|
||||
void app_QueueLoadLevel(App *app, const char *level_name);
|
||||
void _app_SwitchLevel(App *app);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
16
app_file.c
Normal file
16
app_file.c
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "app.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
void app_QueueLoadLevel(App *app, const char *level_name) {
|
||||
if (app->switch_level != NULL) {
|
||||
WARN("previous switch_level \"%s\" not processed; purged", app->switch_level);
|
||||
free(app->switch_level);
|
||||
}
|
||||
app->switch_level = copy_malloc(level_name);
|
||||
}
|
||||
|
||||
void _app_SwitchLevel(App *app) {
|
||||
}
|
Loading…
Reference in New Issue
Block a user