Skip to content

Space Invaders: reclaim off-screen bullets, enforce black playfield, preserve ESC exit#441

Merged
jbampton merged 3 commits intomainfrom
copilot/improve-space-invaders-game
Apr 19, 2026
Merged

Space Invaders: reclaim off-screen bullets, enforce black playfield, preserve ESC exit#441
jbampton merged 3 commits intomainfrom
copilot/improve-space-invaders-game

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

Space Invaders was retaining bullets after they left the visible area, which unnecessarily grows object count over time. This update tightens runtime cleanup and ensures the game renders on an explicit black canvas while keeping fast keyboard exit behavior intact.

  • Memory/runtime cleanup

    • Added per-frame pruning of bullets that move outside the playable viewport.
    • Introduced a named boundary buffer constant to avoid repeated magic numbers and make cleanup bounds explicit.
  • Rendering/background behavior

    • Switched the game from transparent mode to an explicit black background.
    • Set both Phaser scene background and canvas element background to black for consistent full-screen presentation.
  • Input/exit behavior

    • Retained ESC handling to immediately destroy the Space Invaders game instance and remove its canvas.
const BULLET_CLEANUP_BUFFER = 40;

const bullets = this.si_bullets?.getChildren?.() || [];
bullets.forEach((bullet) => {
  if (!bullet.active) return;
  if (
    bullet.y < -BULLET_CLEANUP_BUFFER ||
    bullet.x < -BULLET_CLEANUP_BUFFER ||
    bullet.x > this.scale.width + BULLET_CLEANUP_BUFFER
  ) {
    bullet.destroy();
  }
});

@jbampton jbampton added this to Next Apr 19, 2026
@github-project-automation github-project-automation bot moved this to In progress in Next Apr 19, 2026
@jbampton jbampton added this to the Hackfest milestone Apr 19, 2026
@jbampton jbampton added the good first issue Good for newcomers label Apr 19, 2026
@jbampton jbampton marked this pull request as ready for review April 19, 2026 06:32
@jbampton jbampton self-requested a review as a code owner April 19, 2026 06:32
@jbampton jbampton merged commit 04ec60d into main Apr 19, 2026
12 of 13 checks passed
@jbampton jbampton deleted the copilot/improve-space-invaders-game branch April 19, 2026 06:35
@github-project-automation github-project-automation bot moved this from In progress to Done in Next Apr 19, 2026
Copilot AI added a commit that referenced this pull request Apr 19, 2026
…preserve ESC exit (#441)

* Space Invaders: cleanup offscreen bullets and black canvas background

Agent-Logs-Url: https://github.com/NextCommunity/NextCommunity.github.io/sessions/4a92f727-d408-427a-8bee-fc96696e3d01

Co-authored-by: jbampton <418747+jbampton@users.noreply.github.com>

* Space Invaders: extract bullet cleanup buffer constant

Agent-Logs-Url: https://github.com/NextCommunity/NextCommunity.github.io/sessions/4a92f727-d408-427a-8bee-fc96696e3d01

Co-authored-by: jbampton <418747+jbampton@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jbampton <418747+jbampton@users.noreply.github.com>
Co-authored-by: John Bampton <jbampton@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants