Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to make a PAC MAN imitation game to start working on AI, and while my first version will feature rectangles with widths or heights of 1 to makes walls for collision detection, I want to eventually make walls that are at 45 degree angles. I have found no guides out there to do this, only that rectangles can't be rotated apparently.

share|improve this question
    
having re-read your question and title after posting my answer I am no longer sure you wanted line drawing code, maybe you wanted collision code. Can you clarify? –  Ken Oct 17 '12 at 19:48
    
Yeah, Sorry, I should have made that more clear. I am looking for collision code. thanks for asking –  John Doughty Oct 17 '12 at 20:01
1  
Maybe you could be a bit more specific about what kind of collisions you had in mind. Bounding circles, bounding boxes,pixel perfect... –  Ken Oct 17 '12 at 22:13
    
hmmm, this is all still new to me. I want to allow for the ghosts to be able to avoid them using path finding, but the player i just want to have it so that if they go into a space that has a 45 degree line that it moves them up since PAC MAN is basically auto movement outside of direction changing. Am I clearing things up or making them more murky? –  John Doughty Oct 18 '12 at 0:38
    
this answer has a pretty comprehensive explanation of edge-circle CD gamedev.stackexchange.com/a/18339/4568 –  Ken Oct 18 '12 at 8:50
add comment

1 Answer 1

what your are asking for is analytic geometry. I think there are mainly two scenarios, assuming your wall is only a line:

  1. Your Player's bounding volume is a circle: Calculate distance from center of the circle to line, and check whether it is smaller then the radius. Check out this: Distance from point to line in 2D on Wolfram.
  2. Your Player's bounding volume is a rectangle: Your have to calculate each intersection of the rectangles four lines and check whether one of the intersection lies in between start and end point of one line. Check out this: Line-line intersection on Wikipedia
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.