Back to Forum
PacMan Movement code
EightBitRx posted 4 years ago

Hello,

First, thanks for the PacMan course! I absolutely devoured the freemium and plan to subscribe for the rest.

My issue is with the movement code for the player. It is very difficult to guid PacMan accurately through turns - especially when it comes to quick changes of direction. I feel that many players will instantly sense this difficulty and move on to another game.

I'm trying to improve the code and hope someone else here addressed this and might be willing to post their solution.

Cheers :)

EightBitRx

spacecadet's profile photo
spacecadet posted 4 years ago

I'm just getting into the code now, so maybe I will have better ideas soon. But, as quick first input, I prefer to use the ArrowUp, ArrowDown, ArrowLeft, and ArrowRight keys. But I also noticed a slight movement of the canvas when using them. So, I added this code:

// added minus 5 to prevent canvas from being slightly too large, 
// which caused it to move when using arrow keys
canvas.width = innerWidth - 5
canvas.height = innerHeight - 5

S
SPURTECH posted 4 years ago

Hi guys im having some movement issues too. When I made the map bigger the ghosts started moving through certain parts including the outer edge which is weird. Any suggestions welcome.

Here's my live site....

https://spur-tech.github.io/PACMAN/

Here's my code.....

https://github.com/SPUR-TECH/PACMAN/tree/main

Want to participate?

Create a free Chris Courses account to begin

Providing the lift to launch your development career

© 2026 Chris Courses. All rights reserved.