Automated pr 1782069385155 - #4090
Open
jonasvanleeuwen19 wants to merge 3 commits into
Open
Conversation
|
@jonasvanleeuwen19 is attempting to deploy a commit to the Hack Club Team on Vercel. A member of the Team first needs to authorize it. |
|
[Auto Triage] PR detected. Apply |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Sprig game, “just_snake”, implementing a classic Snake experience with custom sprites, sound effects, background music, wall boundaries, scoring, and restart controls.
Changes:
- Introduces
games/JustSnake.jswith snake movement, collision detection, apple spawning, and score display. - Adds SFX (eat/lose/restart) and looping BGM playback.
- Implements restart-on-
Jand timed movement viasetInterval.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+189
to
+190
| function startGame() { | ||
| playTune(restartSfx) |
Comment on lines
+299
to
+301
| clearText() | ||
| playback.end() | ||
| addText("GAME OVER", { x: 5, y: 0, color: color`2` }) |
Comment on lines
+221
to
+234
| function spawnApple() { | ||
| while (true) { | ||
| let x = Math.floor(Math.random() * width()) | ||
| let y = Math.floor(Math.random() * height()) | ||
|
|
||
| let occupied = snake.some(s => s.x === x && s.y === y) | ||
| let wallHere = getTile(x, y).some(s => s.type === wall) | ||
|
|
||
| if (!occupied && !wallHere) { | ||
| addSprite(x, y, apple) | ||
| break | ||
| } | ||
| } | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (3)
games/JustSnake.js:190
- Restarting the game while a round is still running starts a new background-music playback without stopping the previous one, which can result in overlapping audio. End any existing playback before starting a new game (and consider guarding playback.end() calls).
function startGame() {
playTune(restartSfx)
games/JustSnake.js:300
playback.end()will throw ifplaybackis undefined (e.g., if audio is unavailable or iflose()is called beforestartGame()completes). Guard the call to avoid a hard crash on loss.
playback.end()
games/JustSnake.js:223
spawnApple()uses an unboundedwhile (true)loop. If the board fills up (or there’s no available non-wall tile), this will spin forever and freeze the game.
function spawnApple() {
while (true) {
let x = Math.floor(Math.random() * width())
Comment on lines
+274
to
+285
| if (snake.some(s => s.x === newHead.x && s.y === newHead.y)) | ||
| return lose() | ||
|
|
||
| snake.unshift(newHead) | ||
|
|
||
| if (getTile(newHead.x, newHead.y).some(s => s.type === apple)) { | ||
| getAll(apple).forEach(a => a.remove()) | ||
| playTune(eatSfx) | ||
| spawnApple() | ||
| } else { | ||
| snake.pop() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author name
Author: jonasvanleeuwen19
About your game
What is your game about?
This is the iconic snake game for sprig, complete with sound effects and background music!
How do you play your game?
Use WASD to move the snake
You can press J to restart