Initial commit
This commit is contained in:
52
src/main.c
Normal file
52
src/main.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "engine/core.h"
|
||||
#include "engine/input.h"
|
||||
#include "game/level.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static Level s_level;
|
||||
|
||||
static void game_init(void) {
|
||||
if (!level_load(&s_level, "assets/levels/level01.lvl")) {
|
||||
fprintf(stderr, "Failed to load level!\n");
|
||||
g_engine.running = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void game_update(float dt) {
|
||||
/* Quit on escape */
|
||||
if (input_pressed(ACTION_PAUSE)) {
|
||||
g_engine.running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
level_update(&s_level, dt);
|
||||
}
|
||||
|
||||
static void game_render(float interpolation) {
|
||||
level_render(&s_level, interpolation);
|
||||
}
|
||||
|
||||
static void game_shutdown(void) {
|
||||
level_free(&s_level);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
if (!engine_init()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
engine_set_callbacks((GameCallbacks){
|
||||
.init = game_init,
|
||||
.update = game_update,
|
||||
.render = game_render,
|
||||
.shutdown = game_shutdown,
|
||||
});
|
||||
|
||||
engine_run();
|
||||
engine_shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user