ThatSnail

Diagnosis - Bat Bullet Patterns

Feb 7th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Right, so the bats run this bullet-firing code every so often.
  2.  
  3. var loop,_i;
  4. for(loop=0; loop<360; loop+=45) //fire 8 bullets at 45 degree intervals
  5. {
  6.     _i = instance_create(x, y, oEnemyBulletWiggle);
  7.     _i.direction = loop + sin(degtorad(time)) * 45;
  8. }
  9.  
  10. The bullets themselves (oEnemyBulletWiggle) run this every frame:
  11.  
  12. time += 1;
  13. direction += cos(degtorad(time)) * amount;
  14.  
  15. So the initial direction of the bullet is a function of sin(time) while the change in direction over time is a function of cos(time).  With this system, each bullet fires just a little bit off course, in a systematic way, so as to prevent any "safe" spots.
Advertisement
Add Comment
Please, Sign In to add comment