draw shot

GameStickMan
CalisJI 2024-08-13 23:20:37 +07:00
parent 37956daf7f
commit b279c190cb
1 changed files with 67 additions and 2 deletions

View File

@ -219,6 +219,71 @@ void HeldObject()
dma_display->printf("Score: %d", score); 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 *drawStickMan(int x, int y)
{ {
int range[4]; int range[4];