Ray and Rectangle Collision

Started by
0 comments, last by Basiror 14 years, 11 months ago
I am currently making a basic 2D game and need to determine when a ray (your sprite's laser) collides with a rectangle (the enemy). I also need it to determine which rectangle the ray collides with first and have it return to me the point where the ray and the edge of the rectangle intersect. I would like to know if there is a simple method to calculate this and what the process is for checking this single type of collision as in my game, no other collisions are taken into account. Thanks in advance for your help.
Advertisement
Hello,


have a look at line clipping

http://en.wikipedia.org/wiki/Line_clipping

that should get you started



http://www.8ung.at/basiror/theironcross.html

This topic is closed to new replies.

Advertisement