Adoranda/src/main.c

70 lines
1.3 KiB
C
Raw Normal View History

2021-07-29 18:33:22 +02:00
#include <gint/display.h>
#include <gint/keyboard.h>
2021-08-04 20:12:53 +02:00
#include <gint/timer.h>
#include <gint/clock.h>
2021-08-28 01:32:01 +02:00
#include <gint/usb-ff-bulk.h>
#include "game.h"
#include "engine.h"
#include "player.h"
2021-08-04 20:12:53 +02:00
static int callback_tick(volatile int *tick) {
*tick = 1;
return TIMER_CONTINUE;
2021-07-29 18:33:22 +02:00
}
2021-08-04 20:12:53 +02:00
2022-01-25 22:20:10 +01:00
void take_capture(void) {
if (keydown(KEY_VARS) && usb_is_open()) {
usb_fxlink_screenshot(1);
}
}
2021-08-04 20:12:53 +02:00
int main(void) {
/*Structure definition*/
struct Player player = init_player();
struct Game game = init_game(&player);
2021-08-04 20:12:53 +02:00
/*Timer*/
2021-08-04 20:12:53 +02:00
static volatile int tick = 1;
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000,
GINT_CALL(callback_tick, &tick));
if(t >= 0) timer_start(t);
2021-08-28 01:32:01 +02:00
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
usb_open(interfaces, GINT_CALL_NULL);
2021-12-23 19:21:27 +01:00
/*Font*/
extern font_t uf8x9;
dfont(&uf8x9);
2022-01-25 22:20:10 +01:00
dupdate_set_hook(GINT_CALL(take_capture));
/*Main loop*/
while(1) {
2021-08-04 20:12:53 +02:00
while(!tick) sleep();
tick = 0;
engine_draw(&game);
dupdate();
int action = 0;
while(action != -1) {
action = get_inputs();
if(action == ACTION_MENU) break;
if(action >= DIR_DOWN && action <= DIR_RIGHT)
engine_move(&game, action);
else if(action >= ACTION_SHIFT) {
engine_action(&game, action);
}
2021-08-07 01:49:03 +02:00
}
if(action == ACTION_MENU) break;
2021-08-04 20:12:53 +02:00
engine_tick(&game, ENGINE_TICK);
}
if(t >= 0) timer_stop(t);
2021-08-28 01:32:01 +02:00
usb_close();
2021-08-04 20:12:53 +02:00
return 0;
2021-08-15 03:46:49 +02:00
}