Skip to content

Conversation

@FaizeenHoque
Copy link

Author name

Author: FaizeenHoque

About your game

What is your game about?
In this maze puzzle game, you control a small square player who can move up, down, left, and right. But there’s a twist—every time you move, you leave a solid wall behind you. That means every step you take makes the maze tighter and more challenging.

Your goal is to reach the finish tile on each level without trapping yourself.
Think carefully before moving… one wrong step and you might block your own path!

How do you play your game?
WASD to move

Comment on lines +182 to +192
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)
})
Copy link

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 wall sprites and off-map boundaries due to direct coordinate modification without collision or boundary checks.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The Maze-Game.js code 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 solid wall sprites defined in the game map and also to move off the map boundaries (negative or out-of-bounds coordinates). The setSolids function does not prevent direct coordinate assignment into solid sprites, requiring explicit getTile checks before movement, as demonstrated in BitBoy_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 getTile checks before modifying player coordinates, similar to BitBoy_Adventure.js, to prevent movement into wall sprites and off-map.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: games/Maze-Game.js#L162-L192

Potential issue: The `Maze-Game.js` code 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 solid `wall` sprites defined in the game map and
also to move off the map boundaries (negative or out-of-bounds coordinates). The
`setSolids` function does not prevent direct coordinate assignment into solid sprites,
requiring explicit `getTile` checks before movement, as demonstrated in
`BitBoy_Adventure.js`. This violates intended game mechanics, making walls passable and
potentially leading to undefined behavior off-map.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 5709608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant