GameEngine/source/client.c
Emilia(SleepeeSoftware) 83d93f7803 i am so tired
2026-02-09 15:41:12 +01:00

72 lines
1.6 KiB
C

#include <engine.h>
Assets* LoadAssets() {
Assets *asset = (Assets *)calloc(sizeof(Assets), 1);
assert(asset);
//Font
asset->fonts[DENDRITIC_VOLTAGE] = LoadFont("assets/font/Dendritic_Voltage.ttf");
asset->fonts[LAZENBYCOMP_LIQUID] = LoadFont("assets/font/LazenbyCompLiquid.ttf");
asset->fonts[LAZENBYCOMP_SMOOTH] = LoadFont("assets/font/LazenbyCompSmooth.ttf");
asset->fonts[POTRA] = LoadFont("assets/font/Potra.ttf");
//Textures
//Models
//Sound
//Data
TraceLog(LOG_INFO, "Assets Loaded");
return (asset);
}
void UnloadAssets(Assets *asset) {
UnloadFont(asset->fonts[DENDRITIC_VOLTAGE]);
UnloadFont(asset->fonts[LAZENBYCOMP_LIQUID]);
UnloadFont(asset->fonts[LAZENBYCOMP_SMOOTH]);
UnloadFont(asset->fonts[POTRA]);
free(asset);
}
void UpdateInput() {
const Input input;
int key = GetKeyPressed();
Vector2 mouse_pos = GetMousePosition();
Vector2 mouse_delta = GetMouseDelta();
while (key) {
for (PLAYER_ACTION action = 0; action < 4; action++) {
if (input.key[action] == key) {
//emit("player_intent", action);
break;
}
}
key = GetKeyPressed();
}
}
//may be able to dispatch it
void GameLoop(const double tick_time) {
__thread static double time = 0;
time += GetFrameTime();
if (time >= tick_time) {
// interaction
// simulation
time = 0;
}
}
int main(void) {
double tick_time = 0.4;
SetTraceLogLevel(LOG_ALL);
LoadPipeline();
Assets *assets = LoadAssets();
SetExitKey(KEY_NULL);
while (!WindowShouldClose()) {
UpdateInput();
ComputeIntent();
GameLoop(tick_time);
Rendering();
}
UnloadAssets(assets);
assets = NULL;//to remember to not use it after
UnloadPipeline();
return (0);
}