#include "lzy.h" #include "cfg.h" #include long tick = 0; static void rotate(double *x, double *y, double angle) { const double s = sin(angle); const double c = cos(angle); const double ox = *x; const double oy = *y; *x = ox * c - oy * s; *y = ox * s + oy * c; } static void draw_square(int size, double angle) { double x[4] = { 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, }; for (int i = 0; i < 4; i++) { rotate(&x[i], &y[i], angle); 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]); LZY_DrawLine(x[2], y[2], x[3], y[3]); LZY_DrawLine(x[3], y[3], x[0], y[0]); } void background_draw(void) { tick += 1; LZY_DrawSetColor(BLACK); draw_square(300 * sin((double)tick / 50), (double)tick / 40); draw_square(300 * sin((double)tick / 40), (double)tick / 30); draw_square(300 * sin((double)tick / 30), (double)tick / 20); }