Trails: match erase width to draw width, bright flashing missile head

- Enemy missile trails now drawn 3px thick via drawThickLine() with a
  bright head dot (white) that flashes against the trail color every
  couple of frames, like the Atari 2600
- eraseBombTrail() uses a thicker erase band than the draw (5px, 7px for
  wigging smart bombs) plus a 2px tip circle, so no trail residue is
  left behind when a missile dies or impacts
This commit is contained in:
Dejvino
2026-11-10 22:11:33 +01:00
parent d4e6b4e6be
commit 45ffa87425
+38 -8
View File
@@ -557,6 +557,28 @@ static void fireAuto()
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Trail cleanup // Trail cleanup
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Thick line: `w` parallel lines offset perpendicular to the dominant axis.
// Missile trails are drawn 3px wide, so erase passes must be at least as
// wide or they leave residue.
static void drawThickLine(int x0, int y0, int x1, int y1, int w, uint16_t c)
{
int dx = (x1 > x0) ? x1 - x0 : x0 - x1;
int dy = (y1 > y0) ? y1 - y0 : y0 - y1;
if (dx >= dy) {
for (int i = 0; i < w; i++) {
int off = i - w / 2;
tft.drawLine(x0, y0 + off, x1, y1 + off, c);
}
} else {
for (int i = 0; i < w; i++) {
int off = i - w / 2;
tft.drawLine(x0 + off, y0, x1 + off, y1, c);
}
}
}
#define TRAIL_W 3 // enemy trail thickness (px)
// Does the segment (x0,y0)-(x1,y1) pass within `rad` of (px,py)? // Does the segment (x0,y0)-(x1,y1) pass within `rad` of (px,py)?
static bool linePassesNear(int x0, int y0, int x1, int y1, int px, int py, int rad) static bool linePassesNear(int x0, int y0, int x1, int y1, int px, int py, int rad)
{ {
@@ -575,12 +597,16 @@ static bool linePassesNear(int x0, int y0, int x1, int y1, int px, int py, int r
return ddx * ddx + ddy * ddy <= (long)rad * rad; return ddx * ddx + ddy * ddy <= (long)rad * rad;
} }
// Enemy trails persist while the bomb falls (classic look), but vanish the // Enemy trails persist while the bomb falls (classic look, drawn TRAIL_W px
// moment the bomb is destroyed or reaches the ground, like the Atari 2600. // thick with a 2px head dot), but vanish the moment the bomb is destroyed or
// reaches the ground, like the Atari 2600. The erase band is wider than the
// draw: smart bombs wiggle sideways off the straight path, so their erase
// must sweep a wider corridor.
static void eraseBombTrail(const Bomb &b) static void eraseBombTrail(const Bomb &b)
{ {
tft.drawLine((int)b.sx, (int)b.sy, (int)b.x, (int)b.y, TFT_BLACK); drawThickLine((int)b.sx, (int)b.sy, (int)b.x, (int)b.y,
tft.fillCircle((int)b.x, (int)b.y, 1, TFT_BLACK); b.smart ? 7 : 5, TFT_BLACK);
tft.fillCircle((int)b.x, (int)b.y, 2, TFT_BLACK);
// repair anything the erase swept over // repair anything the erase swept over
if (cross.drawn && linePassesNear((int)b.sx, (int)b.sy, (int)b.x, (int)b.y, if (cross.drawn && linePassesNear((int)b.sx, (int)b.sy, (int)b.x, (int)b.y,
cross.dx, cross.dy, 8)) { cross.dx, cross.dy, 8)) {
@@ -657,10 +683,14 @@ static void updateBombs()
float nxf = b.x + edx * b.speed; float nxf = b.x + edx * b.speed;
float nyf = b.y + edy * b.speed; float nyf = b.y + edy * b.speed;
uint16_t col = b.smart ? TFT_MAGENTA : TFT_RED; uint16_t col = b.smart ? TFT_MAGENTA : TFT_RED;
tft.drawLine((int)b.x, (int)b.y, (int)nxf, (int)nyf, col);
if ((int)nxf != (int)b.x || (int)nyf != (int)b.y) { // Restore the previous head dot to trail color (so the path stays a
tft.fillCircle((int)nxf, (int)nyf, 1, col); // continuous 3px line), extend the trail, then draw the new head: a
} // bright dot that flashes, like the 2600 version.
tft.fillCircle((int)b.x, (int)b.y, 2, col);
drawThickLine((int)b.x, (int)b.y, (int)nxf, (int)nyf, TRAIL_W, col);
uint16_t headCol = (frameCount % 4) < 2 ? TFT_WHITE : col;
tft.fillCircle((int)nxf, (int)nyf, 2, headCol);
b.x = nxf; b.x = nxf;
b.y = nyf; b.y = nyf;