diff --git a/source/main.cpp b/source/main.cpp index 5b2de5b..425fa7d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -317,12 +317,65 @@ void mode_yellue(void) { } } +static void mode_3d_moving_square() { + int ans = 0; + int z = 0; + gfxSet3D(true); + while (aptMainLoop() && ans != 1) { + static const int menu_size = 2; + static const s_uc_menu_element menu[] = { + {"z ", true, &z, -100, 100}, + {"back", false, NULL, 0, 0}, + }; + static auto menuVec = vector(menu, menu + menu_size); + + ans = uc_menu(menuVec); + + gspWaitForVBlank(); + + static const u32 color_back = 0xFFFFFF; + static const u32 color_square = 0xFFFF00; + u16 width, height; + t_color *frame; + frame = (t_color *) gfxGetFramebuffer( + GFX_TOP, GFX_LEFT, &height, &width); + for (int i = 0; i < width * height; i++) + { + int x = i / height - z; + if (x < 0 || x >= width) + continue; + int y = height - i % height - 1; + if (x > 190 && x < 210 && y > 100 && y < 120) + rgb_set(frame[i], color_square); + else + rgb_set(frame[i], color_back); + } + + frame = (t_color *) gfxGetFramebuffer( + GFX_TOP, GFX_RIGHT, &height, &width); + for (int i = 0; i < width * height; i++) + { + int x = i / height + z; + if (x < 0 || x >= width) + continue; + int y = height - i % height - 1; + if (x > 190 && x < 210 && y > 100 && y < 120) + rgb_set(frame[i], color_square); + else + rgb_set(frame[i], color_back); + } + + gfxFlushBuffers(); + gfxSwapBuffers(); + } +} + int main(void) {; gfxInitDefault(); consoleInit(GFX_BOTTOM, NULL); while (aptMainLoop()) { - static const int menu_size = 7; + static const int menu_size = 9; static const s_uc_menu_element menu[] = { {"ugly rainbow", false, NULL, 0, 0}, {"direction", false, NULL, 0, 0}, @@ -331,9 +384,13 @@ int main(void) {; {"3D square", false, NULL, 0, 0}, {"ugly 3D rainbow", false, NULL, 0, 0}, {"yellue", false, NULL, 0, 0}, + {"3D moving square", false, NULL, 0, 0}, + {"quit", false, NULL, 0, 0}, }; static auto menuVec = vector(menu, menu + menu_size); int ans = uc_menu(menuVec); + switch (ans) + {} if (ans == 0) mode_ugly_rainbow(); if (ans == 1) @@ -348,7 +405,11 @@ int main(void) {; mode_ugly_3d_rainbow(); if (ans == 6) mode_yellue(); + if (ans == 7) + mode_3d_moving_square(); + if (ans == 8) + break; gfxSet3D(false); } gfxExit(); -} \ No newline at end of file +}