2021-08-21 11:48:06 +02:00
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/keyboard.h>
|
2021-08-21 14:00:35 +02:00
|
|
|
#include <gint/timer.h>
|
|
|
|
#include <gint/gint.h>
|
|
|
|
#include <gint/cpu.h>
|
|
|
|
|
|
|
|
#include <fxlibc/printf.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2021-08-21 12:10:53 +02:00
|
|
|
#include "duet.h"
|
2021-08-21 11:48:06 +02:00
|
|
|
|
2021-08-21 14:00:35 +02:00
|
|
|
level_t level0 = {
|
2021-08-21 14:08:53 +02:00
|
|
|
.tempo = 1.0,
|
|
|
|
.blocks = (rectmeta_t []){
|
|
|
|
{
|
|
|
|
.time = 0,
|
|
|
|
.shape = Shape_LongBar,
|
|
|
|
.position = Position_Left,
|
|
|
|
.action = Action_Normal
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.time = 1,
|
|
|
|
.shape = Shape_LongBar,
|
|
|
|
.position = Position_Middle,
|
|
|
|
.action = Action_Normal
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.time = 3,
|
|
|
|
.shape = Shape_LongBar,
|
|
|
|
.position = Position_Left,
|
|
|
|
.action = Action_Normal
|
|
|
|
},
|
|
|
|
}
|
2021-08-21 14:00:35 +02:00
|
|
|
};
|
2021-08-21 12:11:24 +02:00
|
|
|
|
2021-08-21 11:48:06 +02:00
|
|
|
int main(void)
|
|
|
|
{
|
2021-08-21 14:08:53 +02:00
|
|
|
volatile int need_frame;
|
|
|
|
struct game game;
|
|
|
|
float dt = 0;
|
|
|
|
int timer;
|
2021-08-21 14:00:35 +02:00
|
|
|
|
2021-08-21 14:08:53 +02:00
|
|
|
__printf_enable_fp();
|
2021-08-21 14:00:35 +02:00
|
|
|
|
|
|
|
|
2021-08-21 14:08:53 +02:00
|
|
|
memset(&game, 0x00, sizeof(struct game));
|
|
|
|
game.level = &level0;
|
2021-08-21 14:00:35 +02:00
|
|
|
|
2021-08-21 14:08:53 +02:00
|
|
|
timer = timer_configure(TIMER_ANY, 33000, GINT_CALL_SET(&need_frame));
|
|
|
|
timer_start(timer);
|
|
|
|
while (1) {
|
|
|
|
dt = (1.0 / 30) * level0.tempo;
|
|
|
|
game.time += 1.0 / 30;
|
2021-08-21 14:00:35 +02:00
|
|
|
|
2021-08-21 14:08:53 +02:00
|
|
|
key_event_t e;
|
|
|
|
while ((e = pollevent()).type != KEYEV_NONE) {
|
|
|
|
if (e.type == KEYEV_DOWN && e.key == KEY_MENU)
|
|
|
|
gint_osmenu();
|
|
|
|
}
|
|
|
|
if (keydown(KEY_7)) {
|
|
|
|
game.player_rota += dt;
|
|
|
|
}
|
|
|
|
if (keydown(KEY_0)) {
|
|
|
|
game.player_rota -= dt;
|
|
|
|
}
|
2021-08-21 14:00:35 +02:00
|
|
|
|
2021-08-21 14:08:53 +02:00
|
|
|
//TODO: physix
|
2021-08-21 14:00:35 +02:00
|
|
|
|
2021-08-21 14:08:53 +02:00
|
|
|
dclear(C_BLACK);
|
|
|
|
dprint(0, 0, C_WHITE, "game time: %.2fs", game.time);
|
|
|
|
dprint(0, 11, C_WHITE, "player rota: %.2f rad", game.player_rota);
|
|
|
|
dupdate();
|
2021-08-21 14:00:35 +02:00
|
|
|
|
2021-08-21 14:08:53 +02:00
|
|
|
while (need_frame == 0)
|
|
|
|
sleep();
|
|
|
|
need_frame = 0;
|
|
|
|
}
|
|
|
|
return (1);
|
2021-08-21 11:48:06 +02:00
|
|
|
}
|