indentation, stupid bugs, etc

This commit is contained in:
Lephenixnoir 2021-08-21 14:08:53 +02:00
parent b282d432f5
commit 798ff9b409
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 56 additions and 82 deletions

View File

@ -9,22 +9,6 @@
#define __BSD_VISIBLE 1
#include <math.h>
//---
// 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);
void drectoid(rect_t const *r, int color);

View File

@ -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);
}

View File

@ -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)));