diff --git a/src/duet.h b/src/duet.h index afacf9e..24cd51b 100644 --- a/src/duet.h +++ b/src/duet.h @@ -9,22 +9,6 @@ #define __BSD_VISIBLE 1 #include -//--- -// Data structures -//--- - -<<<<<<< Updated upstream -typedef struct { - float w, h; /* px */ - float x, y; /* px */ - float vx, vy; /* px/s */ - float r; /* rad */ - float vr; /* rad/s */ -} rect_t; - -======= ->>>>>>> Stashed changes - //--- // Level strucutres //--- @@ -75,6 +59,7 @@ typedef struct { float w, h; /* px */ float x, y; /* px */ float vx, vy; /* px/s */ + float r; /* rad */ float vr; /* rad/s */ } rect_t; @@ -98,4 +83,4 @@ void dcircle(int x, int y, int r, int color, bool fill); void dtriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color); -void drectoid(rect_t const *r, int color); \ No newline at end of file +void drectoid(rect_t const *r, int color); diff --git a/src/main.c b/src/main.c index 6e7916d..2deb497 100644 --- a/src/main.c +++ b/src/main.c @@ -10,70 +10,70 @@ #include "duet.h" level_t level0 = { - .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 - }, - } + .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 + }, + } }; int main(void) { - volatile int need_frame; - struct game game; - float dt = 0; - int timer; + volatile int need_frame; + struct game game; + float dt = 0; + int timer; - __printf_enable_fp(); + __printf_enable_fp(); - memset(&game, 0x00, sizeof(struct game)); - game.level = &level0; + memset(&game, 0x00, sizeof(struct game)); + game.level = &level0; - 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; + 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; - 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; - } + 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; + } - //TODO: physix + //TODO: physix - 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(); + 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(); - while (need_frame == 0) - sleep(); - need_frame = 0; - } - return (1); + while (need_frame == 0) + sleep(); + need_frame = 0; + } + return (1); } diff --git a/src/render.c b/src/render.c index a0a8e6a..b36931a 100644 --- a/src/render.c +++ b/src/render.c @@ -41,17 +41,6 @@ static int max(int x, int y) } void dtriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color) { - if(y2 > y3) { - int tx=x2, ty=y2; - x2=x3, y2=y3; - x3=tx, y3=ty; - } - if(y1 > y2) { - int tx=x1, ty=y1; - x1=x2, y1=y2; - x2=tx, y2=ty; - } - // calcul du rectangle circonscrit au triangle int min_x = max(0, min(x1, min(x2, x3))); int max_x = min(DWIDTH-1, max(x1, max(x2, x3)));