From 7337bd189638c36f4c49f82c0833ef6afed998b5 Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Thu, 10 Feb 2022 22:04:24 -0800 Subject: Miniboss laser dude!!!! and of course all sorts of tweaks --- Sound Effects Index.txt | 2 +- bullets.lua | 9 ++-- draw.lua | 7 +-- enemies.lua | 112 +++++++++++++++++++++++++++++++++++++++++++++++- update.lua | 3 +- waves.lua | 39 ++++++++++++++--- 6 files changed, 152 insertions(+), 20 deletions(-) diff --git a/Sound Effects Index.txt b/Sound Effects Index.txt index f01a34c..9f7cadf 100644 --- a/Sound Effects Index.txt +++ b/Sound Effects Index.txt @@ -24,7 +24,7 @@ 23 Laser Charge (1.5 Seconds) 24 Laser Loop 25 Laser Finished -26 +26 Laser Death 27 Light Respawn 28 Respawn 29 Rewind Checkpoint diff --git a/bullets.lua b/bullets.lua index e96b06b..6d4337e 100644 --- a/bullets.lua +++ b/bullets.lua @@ -74,8 +74,8 @@ function addlaser(x, y, r) 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) + pset(i, laser.y+sin(i/(3/(laser.timer/2))-t())*laser.timer*laser.r/2, 11) + pset(i, laser.y+cos(t()*laser.timer+i/30)*laser.timer*3+sin(i/8.32535+t()), 14) end end end @@ -89,13 +89,14 @@ function addlaser(x, y, r) 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 laser.timer > 1.5 and laser.timer < 3.6 then if not laser.playingsound then - sfx(24) + sfx(24,1) laser.playingsound = true end shake = rnd(8)/laser.timer foreach(players, laser.collide) + foreach(enemies, laser.collide) end --delete laser once its done diff --git a/draw.lua b/draw.lua index d3ed667..2bc4a16 100644 --- a/draw.lua +++ b/draw.lua @@ -48,9 +48,4 @@ if not gamerunning or menuscroll < 1 then end end --- print(#obj) - - --- laser enemy --- spr(64,X+0,y+4,4,2) --- spr(64,x+0,y+20,4,2,false,true) +-- print(#obj) \ No newline at end of file diff --git a/enemies.lua b/enemies.lua index c88b2d9..9b7b08c 100644 --- a/enemies.lua +++ b/enemies.lua @@ -191,7 +191,7 @@ function addballshooter(x, y, health, speed) function enemy.shot(enemy) --explode - explosion(enemy.x+rnd(16), enemy.y+rnd(8)) + explosion(enemy.x+rnd(32), enemy.y+rnd(32)) --and reduce health enemy.health -= 1 enemy.inv = 0.5 @@ -320,5 +320,115 @@ function addtargetingenemy(x, y, health, speed) end end + add(enemies, enemy) +end + +function addlasershooter(x, y, speed, stay) + local enemy = {} + enemy.x = x+128 + enemy.y = y + if stay then enemy.y = 64-20 end + enemy.w = 8*4 + enemy.h = 8*4 + enemy.speed = speed + enemy.stay = stay + enemy.inv = -1 + enemy.health = 36 + enemy.lasertimer = 0 + enemy.firedlaser = false + enemy.shootcooldown = 0 + enemy.moveoffset = 0 + enemy.sinspeed = 4 + + function enemy.draw(enemy) + if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + local damaged = (enemy.health < 12) + local sprite = 64 + if damaged then sprite = 96 end + spr(sprite,enemy.x+0,enemy.y+4,4,2, false, damaged) + spr(sprite,enemy.x+0,enemy.y+20,4,2,false,not damaged) + end + end + + function enemy.shot(enemy) + --explode + explosion(enemy.x, enemy.y) + enemy.inv = 0.5 + --and reduce health + enemy.health -= 1 + if enemy.health > 0 then + sfx(16) + end + end + + function enemy.collide(object) --f this enemy collides with something, do damage to both it and itself. also EXPLODE!!! + 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) + enemy.health -= 2 + end + end + + function enemy.update() + if enemy.x > 90 or (not stay and enemy.lasertimer > 4) then --enemy lerps into place when first added, and if they leave they speed up + enemy.x -= enemy.speed/2 + if enemy.lasertimer > 4 then + enemy.speed += 0.025 + else + enemy.x = enemy.x + 0.03 * (90 - enemy.x); + end + end + + if enemy.lasertimer > 4 and stay then + enemy.y = 64-20 + sin(enemy.moveoffset+enemy.lasertimer/enemy.sinspeed) * 40 + enemy.shootcooldown -= 1/60 + if enemy.shootcooldown < 0 then + enemy.shootcooldown = 0.18 + addbullet(enemy.x+6, enemy.y+20, -1, rnd(2)-1, true, 2) --shoooot!!!!! + sfx(15) -- play shoot sound if on screen + end + end + + if enemy.x <= 90 then + if not enemy.firedlaser then + addlaser(enemy.x+6, enemy.y+20, 10) + enemy.moveoffset = rnd({0,0.5}) --add offset so not moving in same direction each time + enemy.sinspeed = rnd({4,4,4,4,4,4,4,4,4,4,4,4,1,8,2,2,2,2}) --add differing speeds to sin up and down randomly + end + enemy.firedlaser = true + enemy.lasertimer += 1/60 + if enemy.lasertimer > 8 and stay then + enemy.firedlaser = false + enemy.lasertimer = 0 + end + end + + if enemy.health < 8 then --smokes when damaged! copy pasted from ball shooter! + addcircle(enemy.x+12+rnd(8), enemy.y+12+rnd(8), -0.5, -0.2, rnd(8), rnd(1)+0.7, 5, 0) + end + + enemy.inv -= 1/60 + foreach(players, enemy.collide) + + if enemy.x < -32 then + del(enemies, enemy) -- delete enemy if off screen + end + + if enemy.health <= 0 then -- die!!!!! + explosion(enemy.x,enemy.y,32,32) + for i = 1, 40, 1 do + addcircle(enemy.x+rnd(32), enemy.y+rnd(32), sin(t()*2), -rnd(2)-1, 1, 2, rnd({3, 11, 9}), -0.1) + end + addpickup(enemy.x+rnd(32), enemy.y+rnd(32), "health") + addpickup(enemy.x+rnd(32), enemy.y+rnd(32)) + addpickup(enemy.x+rnd(32), enemy.y+rnd(32)) + if shake < 3 then + shake = 6 + end + sfx(26) + del(enemies, enemy) + end + end + add(enemies, enemy) end \ No newline at end of file diff --git a/update.lua b/update.lua index e7b480c..5ccf5c7 100644 --- a/update.lua +++ b/update.lua @@ -5,7 +5,7 @@ if gameover then if respawntimer < 0 then gameover = false foreach(players, function(obj) obj:respawn() end) - setwave(mid(1,currentwave-2,#wave)) + setwave(mid(checkpoint,currentwave-2,#wave)) sfx(29, -2) -- sfx(24) end @@ -19,7 +19,6 @@ if not gamerunning and t() > 1 then if btn(4) then addplayer(18, 60, 16, 18) startgame() - addlaser(60,60,10) -- temp spawning laser on start!!!!! GET RID OF THIS!!!! elseif btn(5) then addplayer(18, 45, 16, 18) addplayer(18, 75, 32, 34) diff --git a/waves.lua b/waves.lua index af30ac5..8cb0b6c 100644 --- a/waves.lua +++ b/waves.lua @@ -3,6 +3,7 @@ currentwave = 1 --THIS IS THE CURRENT WAVE, SHOLD BE 1 UNLESS TESTING SOMETHING currentwavetime = 0 delaytimer = 0 everysecondtimer = 0 +checkpoint = 1 wave[1] = { delay = 2, @@ -114,16 +115,39 @@ wave[7] = { everysecond = function() end, conditions = function() - if #enemies < 2 then return true else return false + if #enemies < 1 then return true else return false end end } wave[8] = { - delay = 1, + delay = 3, + start = function() + addbasicenemy(240, 58, rnd(basicenemysprites), 1, 1.1) + addbasicenemy(240, 68, rnd(basicenemysprites), 1, 0.9) + addbasicenemy(240, 63, rnd(basicenemysprites), 1, 1) + addlasershooter(128, 64, 0.4, true) + + end, + everysecond = function() + if flr(currentwavetime%3) == 2 and rnd(100) < 40 then + for i = 1, rnd(2), 1 do + addbasicenemy(128+rnd(20), rnd(20)+54, rnd(basicenemysprites), 1, 0.6) + end + end + end, + conditions = function() + if #enemies < 1 then checkpoint = currentwave+1 return true else return false + end + end +} + +wave[9] = { + delay = 5, start = function() addtargetingenemy(128,1,3,0.1) - addtargetingenemy(262,60,3,0.2) + addtargetingenemy(262-9,60,3,0.2) + addtargetingenemy(262+9,60,3,0.2) addwallshooter(138, true, 10, 0.4, 0) addwallshooter(144, true, 10, 0.4, 0) addwallshooter(185, false, 10, 0.4, 0) @@ -138,7 +162,7 @@ wave[8] = { end } -wave[9] = { +wave[10] = { delay = 3, start = function() for i = 1, 7, 1 do @@ -153,7 +177,7 @@ wave[9] = { end } -wave[10] = { +wave[11] = { delay = 1, start = function() for i = 1, 3, 1 do @@ -182,12 +206,15 @@ function updatewaves() end if wave[currentwave].conditions() then delaytimer += 1/60 - if delaytimer > wave[currentwave].delay then + if delaytimer > wave[min(currentwave+1, #wave)].delay then everysecondtimer = 0 currentwave += 1 currentwavetime = 0 delaytimer = 0 currentwave = (currentwave - 1) % #wave+1 --temporarily looping the waves + if currentwave < checkpoint then + checkpoint = 1 + end wave[currentwave].start() end end -- cgit