-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Sprig App] Maze Game #3498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FaizeenHoque
wants to merge
1
commit into
hackclub:main
Choose a base branch
from
FaizeenHoque:Automated-PR-1764917382302
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+208
−0
Open
[Sprig App] Maze Game #3498
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| /* | ||
| First time? Check out the tutorial game: | ||
| https://sprig.hackclub.com/gallery/getting_started | ||
|
|
||
| @title: Maze Game | ||
| @author: | ||
| @tags: [] | ||
| @addedOn: 2025-00-00 | ||
| */ | ||
|
|
||
| const player = "p" | ||
| const wall = "w" | ||
| const finish = "f" | ||
|
|
||
| setLegend( | ||
| [ player, bitmap` | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333 | ||
| 3333333333333333` ], | ||
| [ wall, bitmap` | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000 | ||
| 0000000000000000` ], | ||
| [ finish, bitmap` | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666 | ||
| 6666666666666666` ] | ||
| ) | ||
|
|
||
| setSolids([ player, wall ]) | ||
|
|
||
| let level = 0 | ||
| const levels = [ | ||
| map` | ||
| ....p | ||
| .wwww | ||
| .wwwf | ||
| .www. | ||
| .....`, | ||
|
|
||
| // Level 2 | ||
| map` | ||
| p.... | ||
| wwww. | ||
| ..... | ||
| .wwww | ||
| ....f`, | ||
|
|
||
| // Level 3 | ||
| map` | ||
| .w.wf.. | ||
| .....w. | ||
| .ww.w.. | ||
| ..w.w.w | ||
| w.p.w.w | ||
| ww..... | ||
| ww...ww`, | ||
|
|
||
| // Level 4 | ||
| map` | ||
| fw...www..w... | ||
| .www...wwwwww. | ||
| ....w..w.w.... | ||
| ..w...ww.w...w | ||
| .w.ww.w..w.www | ||
| .w..w.w..w.w.. | ||
| ww..w.ww.w.w.. | ||
| .w.......w.w.. | ||
| .wwwwwww...www | ||
| .w...w...w.wpw | ||
| .ww.......ww.w | ||
| .....wwww....w`, | ||
|
|
||
| // Level 5 | ||
| map` | ||
| p.w...ww.w..... | ||
| w.www....w.ww.. | ||
| w.w.www.ww.w.ww | ||
| w.w........w... | ||
| w...ww..w.wwww. | ||
| ww....w.w....w. | ||
| .w.ww.w.w.wwww. | ||
| .w..w.w.w....w. | ||
| .ww...w.wwww.w. | ||
| ....w........w. | ||
| w...w.w.wwww.w. | ||
| w...w.w..wfw.w. | ||
| wwwww.ww.w.w... | ||
| .........w.www. | ||
| ..wwwwww.w.....`, | ||
|
|
||
| // Level 6 | ||
| map` | ||
| wwwwwwwwwwwwwwwwwwww | ||
| w..w.pw.wwwww......w | ||
| w..w..w.....w.www..w | ||
| w.....wwwww.w.w.w..w | ||
| w.w.w.........w.w..w | ||
| w.w.wwwwww.ww.w.w..w | ||
| w.w......w.ww.www..w | ||
| w.w..www.w.ww......w | ||
| w.w......w..wwwwww.w | ||
| w.www.w..ww........w | ||
| w.w...w............w | ||
| w.ww..w.wwwwwwwwwwww | ||
| w.....w.w........www | ||
| w..w..w.wwwwwwwwww.w | ||
| wwwww.......w......w | ||
| w....wwwwww.wwww.w.w | ||
| w.ww..w..........w.w | ||
| w...w.wwwwwwwwwwww.w | ||
| wf..w..............w | ||
| wwwwwwwwwwwwwwwwwwww` | ||
| ] | ||
|
|
||
|
|
||
| setMap(levels[level]) | ||
|
|
||
| setPushables({ | ||
| [ player ]: [] | ||
| }) | ||
|
|
||
| onInput("s", () => { | ||
| const p = getFirst(player) | ||
| const oldX = p.x | ||
| const oldY = p.y | ||
| p.y += 1 | ||
| addSprite(oldX, oldY, wall) | ||
| }) | ||
|
|
||
| onInput("w", () => { | ||
| const p = getFirst(player) | ||
| const oldX = p.x | ||
| const oldY = p.y | ||
| p.y -= 1 | ||
| addSprite(oldX, oldY, wall) | ||
| }) | ||
|
|
||
| onInput("a", () => { | ||
| const p = getFirst(player) | ||
| const oldX = p.x | ||
| const oldY = p.y | ||
| p.x -= 1 | ||
| addSprite(oldX, oldY, wall) | ||
| }) | ||
|
|
||
| onInput("d", () => { | ||
| const p = getFirst(player) | ||
| const oldX = p.x | ||
| const oldY = p.y | ||
| p.x += 1 | ||
| addSprite(oldX, oldY, wall) | ||
| }) | ||
|
|
||
|
|
||
| afterInput(() => { | ||
| const p = getFirst(player) | ||
| const f = getFirst(finish) | ||
|
|
||
| // Check if player reached finish | ||
| if (p && f && p.x === f.x && p.y === f.y) { | ||
| level++ | ||
| if (level < levels.length) { | ||
| setMap(levels[level]) | ||
| } else { | ||
| addText("You win!", { x: 5, y: 5, color: color`3` }) | ||
| } | ||
| } | ||
| }) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Player can move through
wallsprites and off-map boundaries due to direct coordinate modification without collision or boundary checks.Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The
Maze-Game.jscode directly modifies player coordinates (e.g.,p.y += 1,p.x -= 1) without performing collision detection or boundary checks. This allows the player sprite to move into solidwallsprites defined in the game map and also to move off the map boundaries (negative or out-of-bounds coordinates). ThesetSolidsfunction does not prevent direct coordinate assignment into solid sprites, requiring explicitgetTilechecks before movement, as demonstrated inBitBoy_Adventure.js. This violates intended game mechanics, making walls passable and potentially leading to undefined behavior off-map.💡 Suggested Fix
Implement explicit collision detection using
getTilechecks before modifying player coordinates, similar toBitBoy_Adventure.js, to prevent movement intowallsprites and off-map.🤖 Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID:
5709608