I want to make a part in the game where missles are fired at you. I want the missles to veer off toward your charecter, but then keep going if they miss you. I can only get them to go directly to your ship (projectile always looks at ship). I got it to work pritty well by making it always look at the spot just behind you, but If you fly up towards the top of the screen, that spot will be on screen. Any Ideas? Im trying to find an example of what I want on a rom somewhere.
Using timers for movement events is usually a pretty sloppy way of doing movement. I suggest something like this:
+shoot a rocket+
- (Create ROCKET 0,0 from ROCKET LAUNCHER)
- (Set VALUE X of ROCKETS) to ((Y position of SHIP) - (Y position of ROCKET LAUNCHER))/2 + Random(20)
- (Set VALUE Y of ROCKETS) to -20 + Random(20)
+position the rocket+
If ((X position of ROCKETS) > X position of SHIP) AND ((Y position of ROCKETS) < (Y position of SHIP))
- Subtract 1 from (VALUE X of ROCKETS)
If ((X position of ROCKETS) < X position of SHIP) AND ((Y position of ROCKETS) < (Y position of SHIP))
- Add 1 from (VALUE X of ROCKETS)
- Subtract 1 from (VALUE Y of ROCKETS)
- (X position of ROCKETS) to (X position of ROCKETS) + (VALUE X of ROCKETS)/5
- (Y position of ROCKETS) to (Y position of ROCKETS) - (VALUE Y of ROCKETS)/5
you may have to play around with the values when creating the rocket depending on how u want the rocket to move and the size of your screen. The rockets should move more realistically. Plus the code is much cleaner. I typed this up in a hurry so there may be mistakes but I'm sure you get the idea.
This is a tall order. Perhaps you should try asking that somewhere other than the lonely hearts column, after all projectiles with style would have heat thrown all over it, they hardly need to go and look for it.
Yeah, get the direction calculator 2 in one of the bonus packs. Even comes with an example for this kind of thing.
Alternatively, you could code a full physics engine like I did. Object goes at steady velocity when it misses, code a bit of deceleration, then accceleration, then change the velocity .
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.