49 lines
894 B
C
49 lines
894 B
C
#include <engine.h>
|
|
|
|
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)l
|
|
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();
|
|
LoadAssets();
|
|
SetExitKey(KEY_NULL);
|
|
while (!WindowShouldClose()) {
|
|
UpdateInput();
|
|
ComputeIntent();
|
|
//DispatchWorker
|
|
GameLoop(tick_time);
|
|
//joinWorker
|
|
Rendering();
|
|
}
|
|
UnloadAssets();
|
|
UnloadPipeline();
|
|
return (0);
|
|
}
|