prosperon/source/engine/yugine.c

71 lines
1.1 KiB
C
Raw Normal View History

2022-02-06 10:14:57 -06:00
#include "render.h"
2022-02-04 11:36:24 -06:00
#include "camera.h"
#include "window.h"
2022-01-19 16:43:21 -06:00
#include "engine.h"
2022-02-04 11:36:24 -06:00
#include "editor.h"
#include "input.h"
#include "2dphysics.h"
#include "openglrender.h"
#include "gameobject.h"
int physOn = 0;
unsigned int frameCount = 0;
2022-02-06 10:14:57 -06:00
double physMS = sFPS144;
double physlag = 0;
double renderMS = sFPS144;
double renderlag = 0;
2022-02-04 11:36:24 -06:00
struct mCamera camera = {0};
2022-01-19 16:43:21 -06:00
int main(int argc, char **args)
{
2022-02-04 11:36:24 -06:00
camera.speed = 500;
2022-01-19 16:43:21 -06:00
engine_init();
2022-02-06 10:14:57 -06:00
struct mSDLWindow *window = MakeSDLWindow("Untitled Game", 1920, 1080, 0);
2022-01-19 16:43:21 -06:00
2022-02-04 11:36:24 -06:00
openglInit();
2022-01-19 16:43:21 -06:00
editor_init(window);
2022-02-03 09:16:22 -06:00
2022-02-04 11:36:24 -06:00
int quit = 0;
2022-01-19 16:43:21 -06:00
//While application is running
while (!quit) {
2022-02-06 10:14:57 -06:00
deltaT = elapsed_time();
2022-01-19 16:43:21 -06:00
2022-02-06 10:14:57 -06:00
physlag += deltaT;
renderlag += deltaT;
2022-01-19 16:43:21 -06:00
input_poll();
if (physlag >= physMS) {
2022-02-06 10:14:57 -06:00
phys2d_update(physMS);
2022-01-19 16:43:21 -06:00
physlag -= physMS;
}
if (renderlag >= renderMS) {
if (physOn) {
2022-02-04 11:36:24 -06:00
update_gameobjects();
2022-01-19 16:43:21 -06:00
}
2022-02-06 10:14:57 -06:00
camera_2d_update(&camera, renderMS);
2022-01-19 16:43:21 -06:00
openglRender(window, &camera);
editor_render();
2022-02-03 09:16:22 -06:00
2022-01-19 16:43:21 -06:00
window_swap(window);
renderlag -= renderMS;
}
}
engine_stop();
2022-02-04 11:36:24 -06:00
2022-01-19 16:43:21 -06:00
return 0;
}