From 2baf558488b3ff89186ab16060dcde98d7693fcc Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 3 Apr 2026 09:36:35 -0700
Subject: [PATCH] Added a band of stars to act as a subtle border for the game
area
---
game/Maelstrom.h | 1 +
game/Maelstrom_Globals.h | 2 ++
game/game.cpp | 12 ++++++++++++
game/init.cpp | 26 ++++++++++++++++++++++++++
4 files changed, 41 insertions(+)
diff --git a/game/Maelstrom.h b/game/Maelstrom.h
index 1ea9029c..a6f1a53b 100644
--- a/game/Maelstrom.h
+++ b/game/Maelstrom.h
@@ -43,6 +43,7 @@
#define MAX_SPRITES 100
#define MAX_SPRITE_FRAMES 60
#define MAX_STARS 30
+#define MAX_BORDER_STARS 150
#define SHIP_FRAMES 48
#define SPRITES_WIDTH 32
#define SPRITE_PRECISION 4 /* sprite <--> game precision */
diff --git a/game/Maelstrom_Globals.h b/game/Maelstrom_Globals.h
index f3ecbc9a..3bec4e64 100644
--- a/game/Maelstrom_Globals.h
+++ b/game/Maelstrom_Globals.h
@@ -80,6 +80,7 @@ extern void DelayAndDraw(int ticks);
// Functions from init.cpp
extern void SetStar(int which);
+extern void SetBorderStar(int which);
// External variables...
// in main.cpp :
@@ -106,6 +107,7 @@ extern MPoint gShotOrigins[SHIP_FRAMES];
extern MPoint gThrustOrigins[SHIP_FRAMES];
extern MPoint gVelocityTable[SHIP_FRAMES];
extern StarPtr gTheStars[MAX_STARS];
+extern StarPtr gBorderStars[MAX_BORDER_STARS];
extern Uint32 gStarColors[];
extern Uint32 gSpriteCRC;
diff --git a/game/game.cpp b/game/game.cpp
index 612a7627..f4392fde 100644
--- a/game/game.cpp
+++ b/game/game.cpp
@@ -500,6 +500,17 @@ GamePanelDelegate::OnDraw(DRAWLEVEL drawLevel)
screen->DrawPoint(x, y, gTheStars[i]->color);
}
+ for ( i=0; i<MAX_BORDER_STARS; ++i ) {
+ int x = (gBorderStars[i]->xCoord << SPRITE_PRECISION);
+ int y = (gBorderStars[i]->yCoord << SPRITE_PRECISION);
+ GetRenderCoordinates(x, y);
+ if (gZoomGame ||
+ (x >= SPRITES_WIDTH && x < (GAME_WIDTH - SPRITES_WIDTH) &&
+ y >= SPRITES_WIDTH && y < (GAME_HEIGHT - SPRITES_WIDTH))) {
+ screen->DrawPoint(x, y, gBorderStars[i]->color);
+ }
+ }
+
/* -- Blit all the sprites */
OBJ_LOOP(i, gNumSprites)
gSprites[i]->BlitSprite();
@@ -1014,6 +1025,7 @@ GamePanelDelegate::DoHousekeeping()
if ( --gLastStar == 0 ) {
gLastStar = STAR_DELAY;
SetStar(FastRandom(MAX_STARS));
+ SetBorderStar(FastRandom(MAX_BORDER_STARS));
}
/* -- Time for the next wave? */
diff --git a/game/init.cpp b/game/init.cpp
index cf2923fb..c6a15be4 100644
--- a/game/init.cpp
+++ b/game/init.cpp
@@ -58,6 +58,7 @@ MPoint gShotOrigins[SHIP_FRAMES];
MPoint gThrustOrigins[SHIP_FRAMES];
MPoint gVelocityTable[SHIP_FRAMES];
StarPtr gTheStars[MAX_STARS];
+StarPtr gBorderStars[MAX_BORDER_STARS];
Uint32 gStarColors[20];
Uint32 gSpriteCRC = 0;
@@ -228,6 +229,25 @@ void SetStar(int which)
gTheStars[which]->color = gStarColors[FastRandom(20)];
} /* -- SetStar */
+/* ----------------------------------------------------------------- */
+/* -- Set a border star */
+
+void SetBorderStar(int which)
+{
+ // Get initial random coordinates
+ int x, y;
+ do
+ {
+ x = FastRandom(GAME_WIDTH);
+ y = FastRandom(GAME_HEIGHT);
+ } while (x > (2*SPRITES_WIDTH) && x < (GAME_WIDTH - (2*SPRITES_WIDTH)) &&
+ y > (2*SPRITES_WIDTH) && y < (GAME_HEIGHT - (2*SPRITES_WIDTH)));
+
+ gBorderStars[which]->xCoord = x;
+ gBorderStars[which]->yCoord = y;
+ gBorderStars[which]->color = gStarColors[FastRandom(20)];
+} /* -- SetBorderStar */
+
/* ----------------------------------------------------------------- */
/* -- Initialize the stars */
@@ -302,6 +322,12 @@ static void InitStars(void)
gTheStars[index]->color = 0L;
SetStar(index);
}
+
+ for (index = 0; index < MAX_BORDER_STARS; index++) {
+ gBorderStars[index] = new Star;
+ gBorderStars[index]->color = 0L;
+ SetBorderStar(index);
+ }
} /* -- InitStars */