Prog
This commit is contained in:
59
src/main.c
59
src/main.c
@ -5,70 +5,17 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "assert/assert.h"
|
||||
#include "game/game.h"
|
||||
#include "display/render.h"
|
||||
#include "input.h"
|
||||
#include "console/console.h"
|
||||
#include "network/client/client.h"
|
||||
#include "network/server/server.h"
|
||||
#include "util/random.h"
|
||||
|
||||
bool_t exitRequested = false;
|
||||
|
||||
void cmdExit(const consolecmdexec_t *exec) {
|
||||
exitRequested = true;
|
||||
}
|
||||
#include "display/render.h"
|
||||
|
||||
int32_t main(const int32_t argc, const char **argv) {
|
||||
assertInit();
|
||||
randomInit();
|
||||
gameInit();
|
||||
inputInit();
|
||||
renderInit();
|
||||
consoleInit();
|
||||
clientInit();
|
||||
serverInit();
|
||||
|
||||
consoleRegCmd("exit", cmdExit);
|
||||
|
||||
entityInit(&GAME.entities[GAME.entityCount++], ENTITY_TYPE_PLAYER);
|
||||
|
||||
float_t lastPing = -1;
|
||||
float_t time = 0;
|
||||
|
||||
while(true) {
|
||||
inputUpdate();
|
||||
consoleUpdate();
|
||||
serverUpdate();
|
||||
clientUpdate();
|
||||
|
||||
if(!CONSOLE.open) {
|
||||
for(uint32_t i = 0; i < GAME.entityCount; i++) {
|
||||
entity_t *ent = &GAME.entities[i];
|
||||
entityTest(ent);
|
||||
}
|
||||
}
|
||||
while(1) {
|
||||
|
||||
renderresult_t result = renderDraw();
|
||||
if(result != RENDER_OK) break;
|
||||
if(exitRequested) break;
|
||||
|
||||
time += GetFrameTime();
|
||||
if(time - lastPing > 1.0f) {
|
||||
lastPing = time;
|
||||
|
||||
if(CLIENT.state != CLIENT_STATE_CONNECTED) continue;
|
||||
packet_t packet;
|
||||
packetPingCreate(&packet);
|
||||
packetQueuePushOut(&CLIENT.packetQueue, &packet);
|
||||
lastPing = time;
|
||||
}
|
||||
usleep(16 * 1000); // Sleep for 16 milliseconds (60 FPS)
|
||||
}
|
||||
|
||||
serverDispose();
|
||||
clientDispose();
|
||||
renderDispose();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user