Advertisement
19891919

My chasing bullet attack wave

Aug 11th, 2020
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. -- The chasing attack from the documentation example.
  2. Arena.Resize(60,60)
  3. sprite.width(16)
  4. sprite.height(16)
  5.  
  6. chasingbullet = CreateProjectile('fire_ball', Arena.width/2, Arena.height/2)
  7. chasingbullet.SetVar('xspeed', 0)
  8. chasingbullet.SetVar('yspeed', 0)
  9.  
  10. function Update()
  11.     local xdifference = Player.x - chasingbullet.x
  12.     local ydifference = Player.y - chasingbullet.y
  13.     local xspeed = chasingbullet.GetVar('xspeed') / 2 + xdifference / 100
  14.     local yspeed = chasingbullet.GetVar('yspeed') / 2 + ydifference / 100
  15.     chasingbullet.Move(xspeed, yspeed)
  16.     chasingbullet.SetVar('xspeed', xspeed)
  17.     chasingbullet.SetVar('yspeed', yspeed)
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement