From 9a46a94d9bce846541cc2dc820cd510da3561307 Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Wed, 9 Feb 2022 20:17:30 -0800 Subject: added wall shoot sound --- enemies.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/enemies.lua b/enemies.lua index cead73c..7864f1a 100644 --- a/enemies.lua +++ b/enemies.lua @@ -97,6 +97,7 @@ function addwallshooter(x, shootup, health, speed) enemy.health = health enemy.shootcooldown = 0 enemy.speed = speed + enemy.shoottoggle = true function enemy.draw(enemy) if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then @@ -126,14 +127,24 @@ function addwallshooter(x, shootup, health, speed) enemy.shootcooldown -= 1/60 enemy.inv -= 1/60 foreach(players, enemy.collide) - if enemy.shootcooldown < 0 and (t()+enemy.offset)%1>0.5 then - enemy.shootcooldown = 0.08 - local vely = -1 - if shootup then vely = 1 end - addbullet(enemy.x, enemy.y, -speed, vely, true, 2) + if enemy.shootcooldown < 0 then + if (t()+enemy.offset)%1>0.5 then + if not enemy.shoottoggle then --implemented a toggle so that the sound effect for firing gets played only once. + enemy.shoottoggle = true + if enemy.x < 128 then + sfx(18) + end + end + enemy.shootcooldown = 0.08 + local vely = -1 + if shootup then vely = 1 end + addbullet(enemy.x, enemy.y, -speed, vely, true, 2) + else + enemy.shoottoggle = false + end end if enemy.x < -8 then - del(enemies, enemy) + del(enemies, enemy) --if off screen, get deleted nerd end if enemy.health <= 0 then for i = 1, rnd(6)+6, 1 do -- cgit