Shoot in any direction (almost)
This will be pretty similar to an enemy shoot script I guess...
If I know the angle I want to shoot at (and the x/y I'm shooting from of course), how do I work out the move_x/move_y?
Or Someone's way of looping in the missile script.
I have 32 different directions, so multiples of 11.25°
I've been trying trigonometry for a while until my head hurts, now I just feel thick
Edit:
I guess if I have fixed directions in which to shoot I could just hardcode the values... but regardless, this would be useful.
If I know the angle I want to shoot at (and the x/y I'm shooting from of course), how do I work out the move_x/move_y?
Or Someone's way of looping in the missile script.
I have 32 different directions, so multiples of 11.25°
I've been trying trigonometry for a while until my head hurts, now I just feel thick

Edit:
I guess if I have fixed directions in which to shoot I could just hardcode the values... but regardless, this would be useful.
The most straightforward way would be to find an approximation to tan that you can do in DinkC
Something that might work well in DinkC would be find 32 points on a circle that are equal distance from each other. Start from one point and go to the next point by finding the next place on the circle that is at the magic distance to produce 32 points with a round trip
Not something I've thought about though, so could be any easier way
Something that might work well in DinkC would be find 32 points on a circle that are equal distance from each other. Start from one point and go to the next point by finding the next place on the circle that is at the magic distance to produce 32 points with a round trip
Not something I've thought about though, so could be any easier way
Did you take a look at my script here? It also shoots in 32 directions, it just doesn't calculate an angle. So no advanced trigonometry there.
If you want to use sp_move_x() and sp_move_y() it doesn't really pay off to use advanced trigonometry since sp_move_x() and sp_move_y() only take integers anyway. So using all kinds of complicated sine/cosine functions really doesn't add much in terms of accuracy.
If you're interested, the final boss in my contest entry uses my enemy shoot system. It has been changed a little bit from the version I posted before to round numbers rather than truncate them. All this interest in enemy shoot systems almost encourages me to release my own as a development file. (In fact, I might...
)
EDIT: Also, in spite of the system calculating directions based on a square rather than a circle the angles aren't too far off, so in practice these values for &move_x and &move_y could probably be used with satisfying accuracy.

If you want to use sp_move_x() and sp_move_y() it doesn't really pay off to use advanced trigonometry since sp_move_x() and sp_move_y() only take integers anyway. So using all kinds of complicated sine/cosine functions really doesn't add much in terms of accuracy.
If you're interested, the final boss in my contest entry uses my enemy shoot system. It has been changed a little bit from the version I posted before to round numbers rather than truncate them. All this interest in enemy shoot systems almost encourages me to release my own as a development file. (In fact, I might...

EDIT: Also, in spite of the system calculating directions based on a square rather than a circle the angles aren't too far off, so in practice these values for &move_x and &move_y could probably be used with satisfying accuracy.
&move_x: | &move_y: | Angle: | Desired angle: 4 | 0 | 0 | 0 4 | 1 | 14.0 | 11.25 4 | 2 | 26.6 | 22.5 4 | 3 | 36.9 | 33.75 4 | 4 | 45 | 45 3 | 4 | 53.1 | 56.25 2 | 4 | 63.4 | 67.5 1 | 4 | 76.0 | 78.75 0 | 4 | 90 | 90
"Did you take a look at my script here?"
Yes, but the trouble I was having is that enemy shoot scripts have an x/y to aim at (Dink), whereas I need to shoot at the right angle but without any specific coordinates to aim at.
Maybe I just ended up over-complicating things.
I'll play around with it some more later, thanks
Yes, but the trouble I was having is that enemy shoot scripts have an x/y to aim at (Dink), whereas I need to shoot at the right angle but without any specific coordinates to aim at.
Maybe I just ended up over-complicating things.
I'll play around with it some more later, thanks
