aboutsummaryrefslogtreecommitdiff
path: root/enemies.lua
diff options
context:
space:
mode:
author1029chris <1029chris@gmail.com>2022-02-04 17:50:20 -0800
committer1029chris <1029chris@gmail.com>2022-02-04 17:50:20 -0800
commitc3adabae861162b66c1b4499754848d1ffdc0833 (patch)
tree750b9a5d0564c5bae66a3538b0779ec266db8f23 /enemies.lua
parent72801b4200dca4fd47c38a488c8812dc1284a5da (diff)
WAVES!!!!!!!! and other stuff
Diffstat (limited to 'enemies.lua')
-rw-r--r--enemies.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/enemies.lua b/enemies.lua
index 6721a2a..ff8606f 100644
--- a/enemies.lua
+++ b/enemies.lua
@@ -11,12 +11,12 @@ function addbasicenemy(x, y, sprite, health, speed)
enemy.inv = -1
enemy.sprite = sprite
enemy.health = health
- enemy.shootcooldown = 3
+ enemy.shootcooldown = rnd(1)+2
enemy.speed = speed
function enemy.draw(enemy)
local sprite = enemy.sprite
- if flr(sin(time()/5)) ~= 0 then
+ if flr(sin(time()*speed)) ~= 0 then --if the ships heading up, change sprite
sprite += 1
end
spr(sprite, enemy.x, enemy.y, 1,1)
@@ -27,6 +27,7 @@ function addbasicenemy(x, y, sprite, health, speed)
explosion(enemy.x, enemy.y)
--and reduce health
enemy.health -= 1
+ sfx(4)
end
function enemy.collide(object)
@@ -39,12 +40,13 @@ function addbasicenemy(x, y, sprite, health, speed)
function enemy.update()
enemy.x -= speed
- enemy.y += sin(time()/5)*speed
+ enemy.y += sin(time()*speed)*speed
enemy.shootcooldown -= 1/60
foreach(players, enemy.collide)
if enemy.shootcooldown < 0 then
- enemy.shootcooldown = 0.5 + rnd(2)
+ enemy.shootcooldown = 0.5 + rnd(1.5)
addbullet(enemy.x-3, enemy.y, -1, 0, true, 3)
+ sfx(3)
end
if enemy.x < -8 then
del(enemies, enemy)
@@ -59,13 +61,10 @@ function addbasicenemy(x, y, sprite, health, speed)
if shake < 3 then
shake = 2.5
end
+ sfx(2)
del(enemies, enemy)
end
end
add(enemies, enemy)
-end
-
-addbasicenemy(128, 60, rnd(basicenemysprites), 1, 0.2)
-addbasicenemy(128, 90, rnd(basicenemysprites), 1, 0.1)
-addbasicenemy(128, 20, rnd(basicenemysprites), 1, 0.1)
+end \ No newline at end of file