aboutsummaryrefslogtreecommitdiff
path: root/bullets.lua
diff options
context:
space:
mode:
author1029chris <1029chris@gmail.com>2022-02-10 18:22:43 -0800
committer1029chris <1029chris@gmail.com>2022-02-10 18:22:43 -0800
commit3c5f4bf5106d93939c6441f4da70e7830b654a34 (patch)
tree79908379d727029505b4f6fb94475fc952726be0 /bullets.lua
parent261d79999931657a25512c60e53fe322bbbf6f9a (diff)
LASERS!!!!!!!
Diffstat (limited to 'bullets.lua')
-rw-r--r--bullets.lua66
1 files changed, 66 insertions, 0 deletions
diff --git a/bullets.lua b/bullets.lua
index 5bcb91d..e96b06b 100644
--- a/bullets.lua
+++ b/bullets.lua
@@ -45,4 +45,70 @@ function addbullet(x, y, velx, vely, evil, sprite)
end
add(obj, bullet)
+end
+
+function addlaser(x, y, r)
+ local laser = {}
+
+ --lasers!!!!!!!!!!!!!!!
+ laser.x = x
+ laser.y = y
+ laser.r = r
+ laser.timer = 0
+ laser.playingsound = false
+
+ function laser.draw(laser)
+ if laser.timer > 1.5 then
+ local radius = (min(laser.timer*laser.r*0.7,laser.r)+sin(t()*6))-mid(0, laser.timer-3, laser.r)*laser.r
+ for i = -10, laser.x, 1 do
+ line(i, laser.y+radius*sin(t()*3+i/(10+laser.timer^3.5))*1.6, i, laser.y-radius*sin(t()*3+i/(10+laser.timer^3.5))*1.6, 14)
+ pset(i, laser.y+(cos(t()*1.5+i/50)+sin(i/4.32535+t())*2)*radius/1.8, 14)
+ end
+ circfill(laser.x, laser.y, radius, 14)
+ rectfill(-10, laser.y-radius, laser.x, laser.y+radius, 14)
+ circfill(laser.x, laser.y, radius*0.7, 11)
+ rectfill(-10, laser.y-radius*0.7, laser.x, laser.y+radius*0.7, 11)
+ circfill(laser.x, laser.y, radius*0.3, 7)
+ rectfill(-10, laser.y-radius*0.3, laser.x, laser.y+radius*0.3, 7)
+ else
+ circfill(laser.x, laser.y, laser.timer*4+sin(t()*8), 11)
+ circfill(laser.x, laser.y, laser.timer*2+sin(t()*8), 7)
+ for i = mid(-5, laser.x-laser.timer*laser.x,laser.x), laser.x, 1 do
+ pset(i, laser.y+sin(i/6.32535-t())*2, 11)
+ pset(i, laser.y+cos(t()*1.5+i/30)*laser.timer*2+sin(i/8.32535+t()), 14)
+ end
+ end
+ end
+
+ function laser.collide(object)
+ if object.x < laser.x and laser.y+laser.r*2 > object.y+object.h and laser.y-laser.r*2 < object.y and object.inv < 0 then
+ object:shot()
+ end
+ end
+
+ function laser.update(laser)
+ laser.timer += 1/60
+ --collision detection after the warm up
+ if laser.timer > 1.5 and laser.timer < 4.2 then
+ if not laser.playingsound then
+ sfx(24)
+ laser.playingsound = true
+ end
+ shake = rnd(8)/laser.timer
+ foreach(players, laser.collide)
+ end
+
+ --delete laser once its done
+ if laser.timer > 4 then
+ del(obj, laser)
+ sfx(24, -2)
+ sfx(25)
+ for i = 1, 16, 1 do
+ addcircle(rnd(laser.x), laser.y-laser.r/2+rnd(laser.r), -0.5, -0.5, rnd(3), rnd(2), rnd({11,14,7}), 0)
+ end
+ end
+ end
+
+ add(obj, laser)
+ sfx(23)
end \ No newline at end of file