summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-17 11:56:08 +0100
committerkdx <kikoodx@paranoici.org>2023-03-17 12:01:20 +0100
commitb6e8281daa60e60e2ae81569b5547f1e3ac3a72b (patch)
treed671bbbfc090c9824ba21e80a2fff33e3df4d1f6
parent9b549158ef22cc845867ac44c4d333b05fa94a44 (diff)
downloadhyperultra-b6e8281daa60e60e2ae81569b5547f1e3ac3a72b.tar.gz
rotating squares
-rw-r--r--src/background.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/background.c b/src/background.c
index c33492b..623f5e0 100644
--- a/src/background.c
+++ b/src/background.c
@@ -3,8 +3,6 @@
#include <math.h>
static long tick = 0;
-static const int center_x = DISPLAY_WIDTH / 2;
-static const int center_y = DISPLAY_HEIGHT / 2;
static void
rotate(double *x, double *y, double angle)
@@ -14,7 +12,7 @@ rotate(double *x, double *y, double angle)
const double ox = *x;
const double oy = *y;
- *x = ox * c - ox * s;
+ *x = ox * c - oy * s;
*y = ox * s + oy * c;
}
@@ -25,18 +23,18 @@ draw_square(int size, double angle)
size / 2.0,
size / 2.0,
-size / 2.0,
- -size / 2.0
+ -size / 2.0,
};
double y[4] = {
-size / 2.0,
size / 2.0,
size / 2.0,
- -size / 2.0
+ -size / 2.0,
};
for (int i = 0; i < 4; i++) {
rotate(&x[i], &y[i], angle);
- x[i] += center_x;
- y[i] += center_y;
+ x[i] += DISPLAY_WIDTH / 2.0;
+ y[i] += DISPLAY_HEIGHT / 2.0;
}
LZY_DrawLine(x[0], y[0], x[1], y[1]);
LZY_DrawLine(x[1], y[1], x[2], y[2]);
@@ -49,5 +47,7 @@ background_draw(void)
{
tick += 1;
LZY_DrawSetColor(0, 0, 0);
- draw_square(64, (double)tick / 10);
+ draw_square(64 * sin((double)tick / 50), (double)tick / 40);
+ draw_square(64 * sin((double)tick / 40), (double)tick / 30);
+ draw_square(64 * sin((double)tick / 30), (double)tick / 20);
}