I'm trying to suss how to do the following for an idea for a shooter.
The player will be locked to moving in an arc of an ellipse or circle. I need the player to point toward the centre of the circle at all times and bullets fired travel toward the center the out of the edge of the game area.
I'm having trouble with getting the ship to point inwards and the bullets to fire at the correct angle. (although I suspect the two are linked.)
the code I have is dead basic and was knocked up for testing the ship rotation.
The second bit of code is what I have for the bullet path, but it does not take the correct path. I know some correction needs to take place, but I'm not sure how to detect which quadrant the player is in to correct the angle. My maths is quite shakey and does need a in depth refresh.
Thanks
Andy
The player will be locked to moving in an arc of an ellipse or circle. I need the player to point toward the centre of the circle at all times and bullets fired travel toward the center the out of the edge of the game area.
I'm having trouble with getting the ship to point inwards and the bullets to fire at the correct angle. (although I suspect the two are linked.)
the code I have is dead basic and was knocked up for testing the ship rotation.
The second bit of code is what I have for the bullet path, but it does not take the correct path. I know some correction needs to take place, but I'm not sure how to detect which quadrant the player is in to correct the angle. My maths is quite shakey and does need a in depth refresh.
' test rotation, ship should point into the circle. Graphics 800 , 600 image = LoadImage("D:\Program Files\BlitzMax\samples\digesteroids\graphics\ship.png") SetImageHandle(image , 10 , 11) For i = 0 To 360 x = 400 + Sin(i) * 200 y = 300 + Cos(i) * 200 ang = ATan2(x-400,y-300) If ang < 0 Then ang:+360 SetRotation(ang+180) DrawImage(image,x,y) Print i + " " + x +" " + y + " " + ATan2(x-400,y-300) Flip Next WaitKey
' test firing code should always fire into the center and beyond Graphics 800 , 600 While Not KeyDown(KEY_ESCAPE) Cls mx = MouseX() px = 400 + Cos(mx) * 300 py = 300 + Sin(mx) * 200 DrawRect(px, py, 5 ,5) If MouseDown(1) And fire = False fire = True bx = px by = py ang = ATan2(bx-400,by-300) End If If fire = True DrawRect(bx, by, 2 ,2) bx :+ Cos(ang) * 10 by :+ Sin(ang) * 10 End If Flip Wend End
Thanks
Andy