Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bullets = {}
- gforcemult = 1
- timer = 0
- Arena.resize(360, 360)
- function Update()
- timer = timer + 1
- if timer > 16 then
- attractor = CreateProjectile('nova/attractor',0,0)
- end
- if timer%4==0 and timer > 16 and timer < 60 * 2 then
- bullet = 0
- dir = math.rad((timer %90))*4
- bullet = CreateProjectile('nova/pellet', math.sin(dir)*Arena.width*2/4, math.cos(dir)*Arena.width*2/4)
- table.insert(bullets, bullet)
- end
- if timer > 60*3 and gforcemult > -1 and timer < 60*4 then
- gforcemult = gforcemult -0.1
- end
- if timer > 60*4 and gforcemult < 4 then
- gforcemult = gforcemult + 0.4
- end
- if timer > 16 then
- for i=1,#bullets do -- update all bullets based on velocity
- local bullet = bullets[i]
- if bullet.isactive then
- local velx = bullet.GetVar('velx')
- local vely = bullet.GetVar('vely')
- local newposx = bullet.x + velx
- local newposy = bullet.y + vely
- bullet.MoveTo(newposx, newposy)
- xdist = attractor.x - bullet.x
- ydist = attractor.y - bullet.y
- angle = math.atan2(xdist, ydist)
- length = math.sqrt(xdist*xdist + ydist*ydist)
- power = 1/length*length
- velx = velx + power*gforcemult*xdist/length
- vely = vely + power*gforcemult*ydist/length
- if(timer < 60*3) then
- velx = velx * (0.97 - math.max(0, 60-length)/60)
- vely = vely * (0.97 - math.max(0, 60-length)/60)
- else
- velx = velx * (0.97 - (0.001 * length))
- vely = vely * (0.97 - (0.001 * length))
- end
- bullet.SetVar('velx',velx)
- bullet.SetVar('vely',vely)
- end
- end
- end
- end
- function OnHit(bullet)
- bullet.Remove()
- Player.Hurt(2,0.2)
- Audio.PlaySound('hit')
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement