Skip to main content
GameDev.net gamedev.net
🔒 Locked

Ray and Rectangle Collision

Started by Celeborn09 Jun 5, 2009 at 2:12 PM 0 replies 900+ views
Original Post
Celeborn09
Celeborn09
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.
Basiror
Basiror
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.