Quote:
Originally Posted by iSDK
Ok, but how could I determine when the walls were touched?
|
Really?
PacMan is a circle. In the game, walls were either vertical (constant X) or horizontal (constant Y), and you can model them (if not, in point of fact, DRAW THEM) as rectangles.
# Case 1 - vertical wall and Xpacman < Xwall
CGPoint P2W -> CGPointMake( Xpacman + Rpacman/2, Ypacman)
if CGRectContainsPoint( rctWall, P2W) then collision
# Xpacman = X coord, center of PacMan
# Ypacman = Y coord, center of PacMan
# Rpacman = PacMan radius
# Xwall = X coord, center of wall
Won't save you if you rez PacMan __IN__ a wall deliberately, but I'll assume you won't do anything that foolish. Remaining cases left as exercise for student.
DISCLAIMER: not real code ... I get paid for real code. The functions are real, though.