2021-11-10 12:10:04 +01:00
|
|
|
#include "camera.h"
|
2021-11-10 06:15:41 +01:00
|
|
|
#include "conf.h"
|
2021-11-09 22:34:40 +01:00
|
|
|
#include "input.h"
|
2021-11-10 00:37:45 +01:00
|
|
|
#include "level.h"
|
2021-11-10 20:44:53 +01:00
|
|
|
#include "particles.h"
|
2021-11-10 06:15:41 +01:00
|
|
|
#include "player.h"
|
2021-11-16 23:11:16 +01:00
|
|
|
#include "raygint/display.h"
|
2021-11-12 17:49:16 +01:00
|
|
|
#include "results.h"
|
2021-11-12 00:52:28 +01:00
|
|
|
#include "stars.h"
|
2021-11-10 06:15:41 +01:00
|
|
|
#include "vec.h"
|
2021-11-17 14:51:05 +01:00
|
|
|
#ifdef GINT
|
2021-11-10 06:15:41 +01:00
|
|
|
#include <gint/cpu.h>
|
2021-11-12 17:12:13 +01:00
|
|
|
#include <gint/keyboard.h>
|
2021-11-10 06:15:41 +01:00
|
|
|
#include <gint/timer.h>
|
2021-11-17 14:51:05 +01:00
|
|
|
#endif
|
2021-11-12 00:52:28 +01:00
|
|
|
#include <stdlib.h>
|
2021-11-10 00:37:45 +01:00
|
|
|
|
2021-11-10 06:15:41 +01:00
|
|
|
static void update(void);
|
2021-11-10 00:37:45 +01:00
|
|
|
static void draw(void);
|
2021-11-17 14:51:05 +01:00
|
|
|
#ifdef GINT
|
2021-11-10 06:15:41 +01:00
|
|
|
static int callback(volatile int *);
|
2021-11-17 14:51:05 +01:00
|
|
|
#endif
|
2021-11-09 22:28:28 +01:00
|
|
|
|
2021-11-12 17:49:16 +01:00
|
|
|
int time = 0;
|
|
|
|
int deaths = 0;
|
|
|
|
int end = 0;
|
|
|
|
|
2021-11-09 22:34:40 +01:00
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
2021-11-10 06:15:41 +01:00
|
|
|
int timer;
|
|
|
|
int frameskip = 1;
|
|
|
|
volatile int has_ticked = 0;
|
2021-11-12 17:12:13 +01:00
|
|
|
extern bopti_image_t bimg_title;
|
2021-11-12 17:49:16 +01:00
|
|
|
extern font_t font_georgia;
|
2021-11-10 06:15:41 +01:00
|
|
|
|
2021-11-17 14:51:05 +01:00
|
|
|
rDisplayInit();
|
2021-11-12 00:52:28 +01:00
|
|
|
srand(1337);
|
2021-11-17 14:51:05 +01:00
|
|
|
#ifdef GINT
|
2021-11-10 06:15:41 +01:00
|
|
|
timer = timer_configure(TIMER_ANY, 1000000 / TARGET_FPS,
|
|
|
|
GINT_CALL(callback, &has_ticked));
|
|
|
|
timer_start(timer);
|
2021-11-17 14:51:05 +01:00
|
|
|
dfont(&font_georgia);
|
|
|
|
#endif
|
|
|
|
#ifdef RAYLIB
|
|
|
|
SetTargetFPS(60);
|
|
|
|
#endif
|
2021-11-09 22:34:40 +01:00
|
|
|
input_init();
|
2021-11-12 00:52:28 +01:00
|
|
|
stars_init();
|
2021-11-11 16:59:37 +01:00
|
|
|
level_load(0);
|
2021-11-10 12:10:04 +01:00
|
|
|
camera_init(player_pos());
|
2021-11-10 00:37:45 +01:00
|
|
|
|
2021-11-17 14:51:05 +01:00
|
|
|
#ifdef GINT
|
2021-11-12 17:12:13 +01:00
|
|
|
dimage(0, 0, &bimg_title);
|
|
|
|
dupdate();
|
|
|
|
getkey();
|
|
|
|
has_ticked = 0;
|
|
|
|
while (!has_ticked)
|
|
|
|
;
|
|
|
|
has_ticked = 0;
|
2021-11-17 14:51:05 +01:00
|
|
|
#endif
|
2021-11-12 17:12:13 +01:00
|
|
|
|
2021-11-10 23:29:12 +01:00
|
|
|
while (!input_down(K_EXIT)) {
|
2021-11-10 06:15:41 +01:00
|
|
|
int i;
|
2021-11-10 14:05:00 +01:00
|
|
|
draw();
|
2021-11-10 06:15:41 +01:00
|
|
|
for (i = 0; i < frameskip; i++) {
|
2021-11-17 14:51:05 +01:00
|
|
|
#ifdef GINT
|
2021-11-10 06:15:41 +01:00
|
|
|
if (has_ticked > frameskip) {
|
|
|
|
frameskip = has_ticked;
|
|
|
|
}
|
|
|
|
while (!has_ticked)
|
|
|
|
sleep();
|
2021-11-12 17:49:16 +01:00
|
|
|
while (has_ticked) {
|
|
|
|
time += has_ticked;
|
2021-11-10 06:15:41 +01:00
|
|
|
has_ticked = 0;
|
2021-11-12 17:49:16 +01:00
|
|
|
}
|
2021-11-17 14:51:05 +01:00
|
|
|
#endif
|
2021-11-10 06:15:41 +01:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
2021-11-10 00:37:45 +01:00
|
|
|
|
2021-11-17 14:51:05 +01:00
|
|
|
rDisplayDeinit();
|
|
|
|
#ifdef GINT
|
2021-11-10 06:15:41 +01:00
|
|
|
timer_stop(timer);
|
2021-11-17 14:51:05 +01:00
|
|
|
#endif
|
2021-11-10 08:08:29 +01:00
|
|
|
level_free();
|
2021-11-09 22:28:28 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2021-11-10 00:37:45 +01:00
|
|
|
|
2021-11-10 06:15:41 +01:00
|
|
|
static void
|
|
|
|
update(void)
|
|
|
|
{
|
2021-11-10 20:44:53 +01:00
|
|
|
particles_update();
|
2021-11-10 06:15:41 +01:00
|
|
|
input_update();
|
2021-11-10 08:08:29 +01:00
|
|
|
player_update();
|
2021-11-10 12:10:04 +01:00
|
|
|
camera_update();
|
2021-11-12 00:52:28 +01:00
|
|
|
stars_update();
|
2021-11-10 06:15:41 +01:00
|
|
|
}
|
|
|
|
|
2021-11-10 00:37:45 +01:00
|
|
|
static void
|
|
|
|
draw(void)
|
|
|
|
{
|
2021-11-17 14:51:05 +01:00
|
|
|
rDrawBegin();
|
2021-11-10 00:37:45 +01:00
|
|
|
dclear(C_BLACK);
|
2021-11-12 00:52:28 +01:00
|
|
|
stars_draw();
|
2021-11-10 08:08:29 +01:00
|
|
|
level_draw();
|
|
|
|
player_draw();
|
2021-11-10 20:44:53 +01:00
|
|
|
particles_draw();
|
2021-11-12 17:49:16 +01:00
|
|
|
if (end)
|
|
|
|
results_draw();
|
2021-11-10 00:37:45 +01:00
|
|
|
dupdate();
|
2021-11-17 14:51:05 +01:00
|
|
|
rDrawEnd();
|
2021-11-10 00:37:45 +01:00
|
|
|
}
|
2021-11-10 06:15:41 +01:00
|
|
|
|
2021-11-17 14:51:05 +01:00
|
|
|
#ifdef GINT
|
2021-11-10 06:15:41 +01:00
|
|
|
static int
|
|
|
|
callback(volatile int *arg)
|
|
|
|
{
|
|
|
|
*arg += 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2021-11-17 14:51:05 +01:00
|
|
|
#endif
|