Outline for level loading
This commit is contained in:
parent
2a81321b7e
commit
5b00594685
10
app.c
10
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,6 +26,7 @@ App *app_NewApp() {
|
||||
app->camera = camera_NewSystem(app);
|
||||
app->particle = particle_NewSystem(app);
|
||||
|
||||
app->switch_level = NULL;
|
||||
app->wantQuit = false;
|
||||
|
||||
|
||||
@ -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);
|
||||
|
5
app.h
5
app.h
@ -22,6 +22,7 @@ typedef struct _App {
|
||||
System_Camera *camera;
|
||||
System_Particle *particle;
|
||||
|
||||
char *switch_level;
|
||||
bool wantQuit;
|
||||
} App;
|
||||
|
||||
@ -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