Facebook
From Funky Goose, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 319
  1. -- The bouncing bullets attack from the documentation example.
  2. spawntimer = 0
  3. bullets = {}
  4. actbt = {}
  5. Arena.Resize(128, 512)
  6.  
  7. function Update()
  8.     spawntimer = spawntimer + 1
  9.     if spawntimer%15 == 0 then
  10.         local posx = 15 - math.random(30)
  11.         local posy = Arena.height/2
  12.         local bullet = CreateProjectile('money2', posx, posy)
  13.                
  14.         bullet.SetVar('velx', 1 - 2*math.random())
  15.         bullet.SetVar('vely', 0)
  16.         table.insert(bullets, bullet)
  17.     end
  18.        
  19.         --[[if spawntimer == 200 then
  20.                 local posx = 15 - math.random(30)
  21.         local posy = Arena.height/2
  22.         local actBt = CreateProjectile('UI/actbt_0', posx, posy)
  23.         actBt.SetVar('velx', 1 - 2*math.random())
  24.         actBt.SetVar('vely', 0)
  25.                 actBt.SetVar('harmless', true)
  26.         table.insert(actbt, actBt)
  27.         end
  28.     --]]
  29.     for i=1,#bullets do
  30.         local bullet = bullets[i]
  31.         local velx = bullet.GetVar('velx')
  32.         local vely = bullet.GetVar('vely')
  33.         local newposx = bullet.x + velx
  34.         local newposy = bullet.y + vely
  35.         vely = vely - 0.04
  36.         bullet.MoveTo(newposx, newposy)
  37.         bullet.SetVar('vely', vely)
  38.     end
  39.        
  40.         for i=1,#actbt do
  41.         local actBt = actbt[i]
  42.         local velx = actBt.GetVar('velx')
  43.         local vely = actBt.GetVar('vely')
  44.         local newposx = actBt.x + velx
  45.         local newposy = actBt.y + vely
  46.         vely = vely - 0.02
  47.                 actBt.sprite.rotation = actBt.sprite.rotation + 5
  48.                 actBt.MoveTo(newposx, newposy)
  49.         actBt.SetVar('vely', vely)
  50.     end
  51.        
  52.         function OnHit(actBt)
  53.                 if actBt.GetVar('harmless') == true then
  54.                
  55.                 else
  56.                         Player.Hurt(3)
  57.                 end
  58.         end
  59. end