aboutsummaryrefslogtreecommitdiff
path: root/enemies.lua
diff options
context:
space:
mode:
author1029chris <1029chris@gmail.com>2022-02-07 14:50:33 -0800
committer1029chris <1029chris@gmail.com>2022-02-07 14:50:33 -0800
commit30a95588502912f29c49c02d4e9620a26ed28643 (patch)
tree3437b0a4ccce5658b08b5796f1ec7cf9a211c491 /enemies.lua
parentcbb2b65b35e9fe642ff2e6771572251b9c876c30 (diff)
Programed the "ball shooter" and made some changes here and there
Diffstat (limited to 'enemies.lua')
-rw-r--r--enemies.lua80
1 files changed, 79 insertions, 1 deletions
diff --git a/enemies.lua b/enemies.lua
index 73e2f48..98e838f 100644
--- a/enemies.lua
+++ b/enemies.lua
@@ -38,7 +38,7 @@ function addbasicenemy(x, y, sprite, health, speed)
function enemy.collide(object)
if enemy.x+4 >= object.x and enemy.x+4 <= object.x+object.w and enemy.y+4 >= object.y and enemy.y+4 <= object.y+object.h and object.inv < 0 then
object:shot()
- explosion(enemy.x, enemy.y)
+ explosion(enemy.x+4, enemy.y+4)
enemy.health -= 2
end
end
@@ -147,4 +147,82 @@ function addwallshooter(x, shootup, health, speed)
end
add(enemies, enemy)
+end
+
+--Big ol fella that shoots CIRCLES of BULLETS!!!!!!
+
+function addballshooter(x, y, health, speed)
+ local enemy = {}
+ enemy.x = x
+ enemy.y = y
+ enemy.offset = rnd()
+ enemy.w = 8*4
+ enemy.h = 8*2
+ enemy.inv = -1
+ enemy.health = health
+ enemy.shootcooldown = 0
+ enemy.speed = speed
+
+ function enemy.draw(enemy)
+ if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then
+ local sprite = 55
+ if enemy.health < 7 then sprite = 39 end
+ spr(sprite, enemy.x, enemy.y, 4, 1, false, true)
+ spr(sprite, enemy.x, enemy.y+8, 4, 1)
+ end
+ end
+
+ function enemy.shot(enemy)
+ --explode
+ explosion(enemy.x+rnd(16), enemy.y+rnd(8))
+ --and reduce health
+ enemy.health -= 1
+ enemy.inv = 0.5
+ sfx(4)
+ end
+
+ function enemy.collide(object)
+ if enemy.x+4 >= object.x and enemy.x+4 <= object.x+object.w and enemy.y+4 >= object.y and enemy.y+4 <= object.y+object.h and object.inv < 0 then
+ object:shot()
+ explosion(enemy.x+4, enemy.y+4, 8*4, 8*2)
+ enemy.health -= 3
+ end
+ end
+
+ function enemy.update()
+ enemy.x -= speed
+ enemy.shootcooldown -= 1/60
+ enemy.inv -= 1/60
+ foreach(players, enemy.collide)
+ if enemy.shootcooldown < 0 then
+ enemy.shootcooldown = 2
+ for i = 1, 48, 1 do
+ if sin(i/48) < 0.3 and sin((i+currentwavetime)/8) < 0.4 then
+ addbullet(enemy.x+4, enemy.y+4, sin(i/48)/2, cos(i/48)/2, true, 3)
+ end
+ end
+ end
+ if enemy.x < -32 then
+ del(enemies, enemy)
+ end
+ if enemy.health < 8 then
+ addcircle(enemy.x+20+rnd(8), enemy.y+6+rnd(8), -0.5, -0.2, rnd(8), rnd(1.5)+1, 5, 0)
+ end
+ if enemy.health <= 0 then
+ for i = 1, 24, 1 do
+ addcircle(enemy.x+rnd(8), enemy.y+rnd(8), rnd(4)-2, -rnd(2)-1, 1, 2, rnd({3, 11, 9}), -0.1)
+ end
+ if rnd(100) > 80 then
+ addpickup(enemy.x, enemy.y)
+ end
+ if shake < 3 then
+ shake = 12
+ end
+ sfx(2)
+ explosion(enemy.x+4, enemy.y+4, 8*4, 8*2)
+ del(enemies, enemy)
+ end
+ end
+
+ add(enemies, enemy)
end \ No newline at end of file