by bruce » Fri Oct 26, 2007 8:01 pm
If your rocks are roughly circular, then use basically the same detection algorithm, only compare (where x and y are the coordinates of the bullet, x1 and y1 the coordinates of the rock's center, and r the radius of the rock) (x -x1)^2 + (y - y1)^2 <= r^2.
Using circles for the real rock footprint rather than squares makes it look less fakey, since you don't have the "shooting the corner which is nowhere near the rock" problem.
Also, you'll note that the real distance formula would take the square root of all those values. Fuck that; sqrt() is expensive. Multiplication is (usually) cheap.
Bruce
If your rocks are roughly circular, then use basically the same detection algorithm, only compare (where x and y are the coordinates of the bullet, x1 and y1 the coordinates of the rock's center, and r the radius of the rock) (x -x1)^2 + (y - y1)^2 <= r^2.
Using circles for the real rock footprint rather than squares makes it look less fakey, since you don't have the "shooting the corner which is nowhere near the rock" problem.
Also, you'll note that the real distance formula would take the square root of all those values. Fuck that; sqrt() is expensive. Multiplication is (usually) cheap.
Bruce