#9306 - VgSlag - Fri Aug 01, 2003 10:14 am
I'm making asteroids on the GBA as a way for me to learn... I have all the movement working using a fixed point trig lookup table, the asteroid is moving nicely too.
I'm using this fixed point code here: http://members.aol.com/form1/fixed.htm
I'm storing all values as fixed point to keep the speed up then convert it to float when placing the sprites x and y.
My asteroid is a 64 x 64 graphic which when x > 240(as a fixed number) appers at -64(as a fixed number).
For the collision I'm getting the distance between the fixed x of the bullet and fixed x of the asteroid + fixed asteroind radius (distX) and storing it as a fixed also. I'm doing the same with y then working out if it's collided by checking dist = Mulfx(distX, distX) + Mulfx(distY, distY) against the fixed radius of the asteroid squared...
That works fine, it's really nice, my problem is when the asteroid is very near the left or right of the screen, if you're firing left and the asteroid is moving off the right of the screen my shot dissapear asthough hitting an invisible asteroid, the same happens the opposite way round too :(
Once the asteroid has changed fully to the other side it all goes back to normal. Does anyone know why? Is it to do with my numbers getting too high?
ANy help would be greatly, greatly appreciated.
Thanks,
G
I'm using this fixed point code here: http://members.aol.com/form1/fixed.htm
I'm storing all values as fixed point to keep the speed up then convert it to float when placing the sprites x and y.
My asteroid is a 64 x 64 graphic which when x > 240(as a fixed number) appers at -64(as a fixed number).
For the collision I'm getting the distance between the fixed x of the bullet and fixed x of the asteroid + fixed asteroind radius (distX) and storing it as a fixed also. I'm doing the same with y then working out if it's collided by checking dist = Mulfx(distX, distX) + Mulfx(distY, distY) against the fixed radius of the asteroid squared...
That works fine, it's really nice, my problem is when the asteroid is very near the left or right of the screen, if you're firing left and the asteroid is moving off the right of the screen my shot dissapear asthough hitting an invisible asteroid, the same happens the opposite way round too :(
Once the asteroid has changed fully to the other side it all goes back to normal. Does anyone know why? Is it to do with my numbers getting too high?
ANy help would be greatly, greatly appreciated.
Thanks,
G