From b279c190cb7ad6a1d06814bdcd2e52758fe73294 Mon Sep 17 00:00:00 2001 From: CalisJI Date: Tue, 13 Aug 2024 23:20:37 +0700 Subject: [PATCH] draw shot --- src/main.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5807308..621a239 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -203,8 +203,8 @@ void DrawObject(bool deleted = false) } int score = 0; -#define COLOR_BLACK dma_display->color333(0, 0, 0) -#define COLOR_WHITE dma_display->color333(7, 7, 7) +#define COLOR_BLACK dma_display->color333(0, 0, 0) +#define COLOR_WHITE dma_display->color333(7, 7, 7) void HeldObject() { if (Y_vat >= MinY_bar && X_vat - 1 >= MinX_bar && X_vat + 1 <= MaxX_bar) @@ -219,6 +219,71 @@ void HeldObject() dma_display->printf("Score: %d", score); } } + +// Stickman + +int X_shot = 0; +int Y_shot = 32; +bool created_shot = false; +bool direction = false; +void Drawshot(bool deleted = false) +{ + // measure x dimension + + if (!created_shot) + { + int ran = random(1, 3); + if (ran == 1) + { + X_shot = 1; + direction = false; + } + else + { + X_shot = 126; + direction = true; + } + created_shot = true; + } + else + { + if (direction == false) + { + X_shot += 1; + } + else + { + X_shot -= 1; + } + } + int min_x = X_shot - 1; + int max_x = X_shot; + int min_y = Y_shot - 1; + int max_y = Y_shot; + if (deleted) + { + for (int i = min_x; i <= max_x; i++) + { + for (int j = min_y; j <= max_y; j++) + { + if (j <= 32) + dma_display->drawPixelRGB888(i, j, 0, 0, 255); + else + dma_display->drawPixelRGB888(i, j, 0, 255, 0); + } + } + } + else + { + for (int i = min_x; i <= max_x; i++) + { + for (int j = min_y; j <= max_y; j++) + { + dma_display->drawPixelRGB888(i, j, 0, 0, 0); + } + } + } +} int *drawStickMan(int x, int y) { int range[4];