Skip to content

fix: snap ghosts to grid on wall collision to prevent corner jitter - #54

Open
yashshinde2 wants to merge 1 commit into
dishu4u:mainfrom
yashshinde2:fix/ghost-corner-jitter
Open

fix: snap ghosts to grid on wall collision to prevent corner jitter#54
yashshinde2 wants to merge 1 commit into
dishu4u:mainfrom
yashshinde2:fix/ghost-corner-jitter

Conversation

@yashshinde2

Copy link
Copy Markdown

Problem

Ghosts get stuck or jitter at corners during gameplay due to
pixel misalignment when changing direction after wall collision.

Root Cause

When a ghost hits a wall and backs up, its x/y position is not
perfectly aligned to the tile grid. This causes all subsequent
direction attempts to fail collision checks, making the ghost
appear stuck or jittery.

Fix

Added grid-snapping (Math.round) after wall collision so ghost
aligns to nearest tile before picking a new direction.

Changes

  • PacMan.java: Added 2 lines in move() method

Closes #[paste your issue number here]

@yashshinde2 yashshinde2 mentioned this pull request Jun 20, 2026
@tanuchoudhary09

Copy link
Copy Markdown

Have been working on java since a long time, @yashshinde2.
Would you please assign me this?

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.

2 participants