diff options
| -rw-r--r-- | bullets.lua | 9 | ||||
| -rw-r--r-- | draw.lua | 39 | ||||
| -rw-r--r-- | enemies.lua | 94 | ||||
| -rw-r--r-- | objects.lua | 5 | ||||
| -rw-r--r-- | pickups.lua | 25 | ||||
| -rw-r--r-- | players.lua | 6 | ||||
| -rw-r--r-- | update.lua | 20 | ||||
| -rw-r--r-- | waves.lua | 141 |
8 files changed, 189 insertions, 150 deletions
diff --git a/bullets.lua b/bullets.lua index bc9fc22..c4eee06 100644 --- a/bullets.lua +++ b/bullets.lua @@ -1,3 +1,5 @@ +despawnallbullets = false + function addbullet(x, y, velx, vely, good, sprite) local bullet = { } @@ -37,7 +39,7 @@ function addbullet(x, y, velx, vely, good, sprite) end --delete bullet if off screen - if y > 128 or y < -8 or x > 128 or x < -8 then + if y > 128 or y < -8 or x > 128 or x < -8 or despawnallbullets then del(obj, bullet) end end @@ -53,12 +55,11 @@ function addlaser(x, y, r, enemy) playingsound = false function laser:draw() - --local mid,line,pset,circfill,rectfill,sin,cos,t = mid,line,pset,circfill,rectfill,sin,cos,t - --local _ENV = self if timer > 1.5 then local radius = (min(timer*r*0.7,r)+sin(t()*6))-mid(0, timer-3, r)*r for i = -10, x, 1 do - line(i, y+radius*sin(t()*3+i/(10+timer^3.5))*1.6, i, y-radius*sin(t()*3+i/(10+timer^3.5))*1.6, 14) + local offset = radius*sin(t()*3+i/(10+timer^3.5))*1.6 + line(i, y+offset, i, y-offset, 14) pset(i, y+(cos(t()+i/50)+sin(i/4.32535+t())*2)*radius/1.8, 14) end --circfill(x, y, radius, 14) @@ -1,13 +1,14 @@ --pallete replacement -pal(15,140,1) -pal(14,3,1) --5 tokens -pal(13,133,1) -pal(11,139,1) -pal(10,137,1) -pal(8,136,1) -pal(4,141,1) -pal(3,131,1) -pal(0,130,1) +pal({1,2,131,141,5,6,7,136,9,137,139,12,133,3,140,130}, 1) --don't ask me why, but this table of colors starts at 1, and 0 is the final color +-- pal(15,140,1) +-- pal(14,3,1) --5 tokens +-- pal(13,133,1) +-- pal(11,139,1) +-- pal(10,137,1) +-- pal(8,136,1) +-- pal(4,141,1) +-- pal(3,131,1) +-- pal(0,130,1) @@ -15,18 +16,18 @@ drawbg() drawobjs() camera() --so the score doesn't shake if gamerunning then - local scoreflash = false if gameover then --gameover timer, it does a cute spinny! 😵 printdropshadow(ceil(respawntimer),63+circletimex,55+circletimey,6,5) - runningscore(currentscore,true) --flashes score - elseif players[1].health <=0 then - printdropshadow(ceil(players[1].inv),players[1].x+circletimex,players[1].y+circletimey,12,15) - runningscore(currentscore,true) --flashes score - elseif #players > 1 and players[2].health <=0 then - printdropshadow(ceil(players[2].inv),players[2].x+circletimex,players[2].y+circletimey,9,2) - runningscore(currentscore,true) --flashes score + runningscore(currentscore,true) else - runningscore(currentscore,false) --current game score + runningscore(currentscore,false) + local textcolors = {{12,15},{9,2}} + for i = 1, #players, 1 do + local player = players[i] + if player.health < 1 then + printdropshadow(ceil(player.inv),player.x+circletimex,player.y+circletimey,textcolors[i][i],textcolors[i][i+1]) + end + end end end if not gamerunning or menuscroll < 1 then @@ -56,7 +57,7 @@ if not gamerunning or menuscroll < 1 then end --final score screen and outro transition -if currentwave == 18 then +if currentwave == 20 then finalscorescreen(0,0) --outro acid transition diff --git a/enemies.lua b/enemies.lua index 06a0c0b..d29d826 100644 --- a/enemies.lua +++ b/enemies.lua @@ -22,23 +22,27 @@ function enemycollide(enemy, object) --f this enemy collides with something, do end function enemydie(enemy, sound, soundchannel, points, isboss) + local x,y = enemy.x,enemy.y for i = 1, rnd(enemy.h)+6, 1 do - addcircle(enemy.x+rnd(enemy.w), enemy.y+rnd(enemy.h), rnd(4)-2, -rnd(2)-1, 1, 2, rnd({3, 11, 9}), -0.1) + addcircle(x+rnd(enemy.w), y+rnd(enemy.h), rnd(4)-2, -rnd(2)-1, 1, 2, rnd({3, 11, 9}), -0.1) end if rnd(100) < sqrt(enemy.w*enemy.h)/1.5 then --you get a better chance of a randomly dropped health from bigger enemies - addpickup(enemy.x+rnd(enemy.w), enemy.y+rnd(enemy.h), "health") + addpickup(x+rnd(enemy.w), y+rnd(enemy.h), "health") end - if isboss then - addpickup(enemy.x+rnd(32), enemy.y+rnd(32)) - addpickup(enemy.x+rnd(32), enemy.y+rnd(32), "health") + if isboss and not gameover then + music(-1, 3000) + despawnallbullets = true + addpickup(x+rnd(32), y+rnd(32)) + addpickup(x+rnd(32), y+rnd(32), "health") end if shake < 3 then shake = enemy.h/2 end currentscore += points sfx(sound, soundchannel) - explosion(enemy.x, enemy.y, enemy.w, enemy.h) + explosion(x, y, enemy.w, enemy.h) del(enemies, enemy) + enemy.x,enemy.y = x,y end function enemymisc(enemy) --misc stuff every enemy needs @@ -76,7 +80,7 @@ function addbasicenemy(x, y, speed) --basic small weak enemy if flr(sin(time()*speed)) ~= 0 then --if the ships heading up, change sprite sprite += 1 end - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + if enemy.inv < 0 or flashtime == 1 then spr(sprite, enemy.x, enemy.y) end end @@ -128,7 +132,7 @@ function addwallshooter(x, shootup, health, speed, offset, bulletspeed) if enemy.health < health*0.25 then damagesmoke(enemy) end - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + if enemy.inv < 0 or flashtime == 1 then spr(enemy.sprite+t()*10%2, enemy.x, enemy.y) end end @@ -178,7 +182,7 @@ function addballshooter(x, y, speed) } function enemy.draw(enemy) - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + if enemy.inv < 0 or flashtime == 1 then local sprite = 11 if enemy.health < 4 then damagesmoke(enemy) @@ -230,7 +234,7 @@ function addtargetingenemy(x, y, speed) if enemy.health < 2 then damagesmoke(enemy) end - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + if enemy.inv < 0 or flashtime == 1 then spr(58, enemy.x, enemy.y, 2, 1) end end @@ -267,7 +271,7 @@ function addlasershooter(x, y, points, speed, stay, isboss) speed = speed, stay = stay, inv = -1, - health = 36 * #players, -- double health if 2 player --36 + health = 42 * #players, -- double health if 2 player --42 lasertimer = 0, firedlaser = false, shootcooldown = 0, @@ -276,10 +280,10 @@ function addlasershooter(x, y, points, speed, stay, isboss) shot = enemyshot, collide = enemycollide } - if stay then enemy.y = 64-20 end + if stay then enemy.y = 44 end function enemy:draw() - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + if enemy.inv < 0 or flashtime == 1 then local sprite = 64 if enemy.health < 10 then damagesmoke(enemy) @@ -296,7 +300,7 @@ function addlasershooter(x, y, points, speed, stay, isboss) if enemy.lasertimer > 4 then enemy.speed += 0.025 else - enemy.x = enemy.x + 0.03 * (90 - enemy.x); + enemy.x = lerp(enemy.x, 90, 0.03) end end @@ -329,9 +333,6 @@ function addlasershooter(x, y, points, speed, stay, isboss) enemymisc(enemy) if enemy.health <= 0 then -- die!!!!! - if stay then - music(-1, 3000) - end enemydie(enemy,21,3,points,isboss) end end @@ -351,7 +352,7 @@ function addwallboss(x, y, length, points, speed, stay, move, isboss) w = 16, h = 8*length, inv = -1, - health = 10*length*#players, --10 + health = 3.5*length*#players, --3.5 shootcooldown = 3, speed = speed, bulletfired = {}, @@ -359,6 +360,7 @@ function addwallboss(x, y, length, points, speed, stay, move, isboss) collide = enemycollide } enemy.starthealth = enemy.health + if enemy.isboss then enemy.health *= 3 end -- triple health if the boss for i = 1, length, 1 do enemy.bulletfired[i] = 0 @@ -371,7 +373,7 @@ function addwallboss(x, y, length, points, speed, stay, move, isboss) damagesmoke(enemy) dmg = 16 end - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + if enemy.inv < 0 or flashtime == 1 then for i = 2, length-1, 1 do spr(93+enemy.bulletfired[i]+dmg, x, -8+y+i*8) if i < length-2 then @@ -390,7 +392,7 @@ function addwallboss(x, y, length, points, speed, stay, move, isboss) if not enemy.stay then enemy.x -= speed else - enemy.x = enemy.x + 0.025 * (102 - enemy.x); --lerp if boss + enemy.x = lerp(enemy.x, 102, 0.025) --lerp if boss enemy.move = flr((currentwavetime/5)%5) -- loops through moveset end if enemy.shootcooldown < 0 then @@ -434,7 +436,6 @@ function addwallboss(x, y, length, points, speed, stay, move, isboss) end enemymisc(enemy) if enemy.health <= 0 then -- die!!!!! - music(-1, 3000) enemydie(enemy,21,3,points,isboss) end end @@ -457,19 +458,20 @@ function addbomb(x, y, delay) --BIG BOMB!!!! KILL IIT QUICKLY!!!! local points = 50 --points by default if killed by player function enemy.draw(enemy) + local x,y = enemy.x,enemy.y local sprite = 73 if everysecondtimer > 0.5 then sprite = 75 end --animation if enemy.health < 7 then damagesmoke(enemy) sprite += 32 end - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then - circfill(enemy.x+15, enemy.y+16, sin(enemy.shootcooldown^2)*3-enemy.shootcooldown, rnd({7,11,3})) + if enemy.inv < 0 or flashtime == 1 then + circfill(x+15, y+16, sin(enemy.shootcooldown^2)*3-enemy.shootcooldown, rnd({7,11,3})) local offset = mid(0, -enemy.shootcooldown-2, 3) - spr(sprite, enemy.x, enemy.y-offset, 2, 2) - spr(sprite, enemy.x, enemy.y+16+offset, 2, 2, false, true) - spr(sprite, enemy.x+15, enemy.y-offset, 2, 2, true) - spr(sprite, enemy.x+15, enemy.y+16+offset, 2, 2, true, true) + spr(sprite, x, y-offset, 2, 2) + spr(sprite, x, y+16+offset, 2, 2, false, true) + spr(sprite, x+15, y-offset, 2, 2, true) + spr(sprite, x+15, y+16+offset, 2, 2, true, true) end end @@ -484,7 +486,7 @@ function addbomb(x, y, delay) --BIG BOMB!!!! KILL IIT QUICKLY!!!! sfx(8,-2) end elseif enemy.shootcooldown < 0 then - enemy.x = enemy.x + 0.02 * (80 - enemy.x); + enemy.x = lerp(enemy.x, 80, 0.02) end enemymisc(enemy) if enemy.health <= 0 then -- die!!!!! @@ -528,7 +530,7 @@ function addmissileboss(x, y) --boss that shoots missiles!!! sprite = 100 damagesmoke(enemy) end - if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then + if enemy.inv < 0 or flashtime == 1 then spr(sprite, enemy.x, enemy.y, 4, 2) spr(sprite, enemy.x, enemy.y+16, 4, 2, false, true) end @@ -545,8 +547,8 @@ function addmissileboss(x, y) --boss that shoots missiles!!! enemy.targetx = players[playertarget].x+24 enemy.shootcooldown = 0.4 end - enemy.x = enemy.x + enemy.speed * (enemy.targetx - enemy.x); - enemy.y = enemy.y + enemy.speed * (enemy.targety - enemy.y); + enemy.x = lerp(enemy.x, enemy.targetx, enemy.speed) + enemy.y = lerp(enemy.y, enemy.targety, enemy.speed) if enemy.targetchangetimer < 0 then enemy.targetchangetimer = rnd(0.3)+0.5 enemy.targetx = 80+rnd(16) @@ -585,8 +587,8 @@ function addfinalboss() --THE FINAL BOSS!!!!!!! WOOOAAAHHHHHH!!!!!!!!!!!!!!!!!!! w = 32, h = 120, inv = -1, - health = 150, - shootcooldown = rnd(2)+1, + health = 150*#players, --150 + shootcooldown = 4, shot = enemyshot, collide = enemycollide, speed = 1.5, @@ -625,10 +627,28 @@ function addfinalboss() --THE FINAL BOSS!!!!!!! WOOOAAAHHHHHH!!!!!!!!!!!!!!!!!!! function enemy.update() enemy.y = 10+sin(time()*enemy.speed+0.2)*2 --bouncy!!!! - enemy.x = enemy.x + 0.025 * (103 - enemy.x); --lerps into place - -- if enemy.shootcooldown < 0 then - -- enemy.shootcooldown = 0.5 + rnd(1.5) - -- end + enemy.x = lerp(enemy.x, 103, 0.025)--lerps into place + if enemy.shootcooldown < 0 then + enemy.shootcooldown = 1 + addbasicenemy(115,rnd(30)+50,0.4+rnd(0.6)) + if flr(currentwavetime%14+8) == 13 then + local moves = { + function() + addballshooter(110, 48, 0.08) + addballshooter(110, 72, 0.08) + end, + function() + addwallboss(110, 35, 7, 30, 0.05, false, 3, false) + end, + function() + for i = 1, 7, 1 do + addwallshooter(100 + (54-i)*i, (i%2==1), 10, 0.4) + end + end, + } + moves[flr((currentwavetime/14)%#moves+1)]() + end + end enemymisc(enemy) if enemy.health <= 0 then -- die!!!!! enemydie(enemy,17,2,1000) diff --git a/objects.lua b/objects.lua index 2fc11d3..ccfd052 100644 --- a/objects.lua +++ b/objects.lua @@ -27,6 +27,7 @@ function updateobjs() foreach(players, function(obj) obj:update() end) foreach(enemies, function(obj) obj:update() end) foreach(obj, function(obj) obj:update() end) + despawnallbullets = false end function drawobjs() @@ -34,4 +35,8 @@ function drawobjs() foreach(enemies, function(obj) obj:draw() end) clip() --for the final boss foreach(players, function(obj) obj:draw() end) +end + +function lerp(start, destination, amount) + return start + amount * (destination - start); end
\ No newline at end of file diff --git a/pickups.lua b/pickups.lua index 5634c18..74e7073 100644 --- a/pickups.lua +++ b/pickups.lua @@ -20,11 +20,11 @@ function addpickup(x, y, type) type = type or rnd({"fastshoot", "3shoot"}) function pickup.draw(pickup) - sprite = 4 --had to move these checks into draw or they'd have incorrect sprites + local sprite = 4 --had to move these checks into draw or they'd have incorrect sprites if type == "fastshoot" then sprite = 20 elseif type == "3shoot" then - sprite = 36 --health + sprite = 36 end spr(sprite, x, y) @@ -33,26 +33,23 @@ function addpickup(x, y, type) function pickup.collide(player) if x+4 >= player.x-4 and x+4 <= player.x+4+player.w and y+4 >= player.y-4 and y+4 <= player.y+player.h+4 and player.health > 0 then pickup:affect(player) - for i = 1, 8, 1 do - local color = 8 - if type == "fastshoot" then - color = 12 - elseif type == "3shoot" then - color = 9 --health - end - addcircle(x, y, sin(i/8), cos(i/8), 2, 0.6, color) - end del(obj, pickup) end end function pickup:affect(player) - if type == "health" then - player.health = 3 - elseif type == "fastshoot" then + local color = 8 + if type == "fastshoot" then player.shootspeed = 0.1 + color = 12 elseif type == "3shoot" then player.shoot3 = true + color = 9 + else + player.health = 3 + end + for i = 1, 8, 1 do + addcircle(x, y, sin(i/8), cos(i/8), 2, 0.6, color) end currentscore+=10 --10 points sfx(30, 1) diff --git a/players.lua b/players.lua index 82c77ab..e13f2ce 100644 --- a/players.lua +++ b/players.lua @@ -68,11 +68,7 @@ function addplayer(x, y, sprite, bulletsprite) addcircle(player.x+4, player.y+4, sin(i/8), cos(i/8), 2, 0.6, 7) end --normal and light respawn sfx for co-op - if #players == 1 then - sfx(27, 1) - else - sfx(28, 1) - end + sfx(26+#players,1) end function player:update() @@ -22,22 +22,20 @@ elseif gamerunning then end gt += scrollspeed + 1/600 -if currentwave == 18 then --ending screen +if currentwave == 20 then --ending screen if btn(4) and btn(5) and not isoutro then --press both buttons to reset cart acidcounter = 2 isoutro = true music(-1, 2000) --fades music end -else --main menu - if not gamerunning and t() > 1 then - if btn(4) then - addplayer(18, 60, 16, 18) - startgame() - elseif btn(5) then - addplayer(18, 45, 16, 18) - addplayer(18, 75, 32, 34) - startgame() - end +elseif not gamerunning and t() > 1 then --main menu + if btn(4) then + addplayer(18, 60, 16, 18) + startgame() + elseif btn(5) then + addplayer(18, 45, 16, 18) + addplayer(18, 75, 32, 34) + startgame() end end @@ -4,7 +4,7 @@ currentwavetime = 0 delaytimer = 0 everysecondtimer = 0 checkpoint = 1 -changedmusic = false +bossmusic = false --NOTE - slow BG during boss waves / make bosses their own checkpoint @@ -82,7 +82,30 @@ wave[5] = { } wave[6] = { - delay = 0, + delay = 2, + start = function() + addbasicenemy(240, 58, 1.1) + addbasicenemy(240, 68, 0.9) + addbasicenemy(240, 63, 1) + addlasershooter(128, 64, 100, 0.4, true, true) + + end, + everysecond = function() + if rnd(100) < 10 and #enemies > 1 then + for i = 1, rnd(2), 1 do + addbasicenemy(128+rnd(20), rnd(20)+54, 0.6) + end + end + end, + conditions = function() + if #enemies < 1 then checkpoint = currentwave+1 return true + end + end, + boss = true +} + +wave[7] = { + delay = 5, start = function() addballshooter(128, 56, 0.1) addballshooter(160, 14, 0.1) @@ -90,7 +113,7 @@ wave[6] = { end, } -wave[7] = { +wave[8] = { delay = 1, start = function() addballshooter(140, 56, 0.2) @@ -103,33 +126,8 @@ wave[7] = { end, } ---music doesnt transition yet -wave[8] = { - delay = 1, - start = function() - music(9, 0, 3) - changedmusic = true - addbasicenemy(240, 58, 1.1) - addbasicenemy(240, 68, 0.9) - addbasicenemy(240, 63, 1) - addlasershooter(128, 64, 100, 0.4, true, 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, 0.6) - end - end - end, - conditions = function() - if #enemies < 1 then checkpoint = currentwave+1 return true - end - end -} - wave[9] = { - delay = 5, + delay = 1, start = function() addtargetingenemy(128,1,0.1) addtargetingenemy(262,60,0.2) @@ -149,7 +147,8 @@ wave[10] = { delay = 3, start = function() for i = 1, 7, 1 do - addtargetingenemy(128, i*16-4, 0.1) + addtargetingenemy(128, i*16-4, 0.085) + addtargetingenemy(144, i*16-4, 0.085) end end, conditions = function() @@ -169,16 +168,14 @@ wave[11] = { end, } ---music doesnt transition yet wave[12] = { - delay = 1, + delay = 2, start = function() - music(9, 0, 3) - changedmusic = true addwallboss(128,4,15,225,0.05,true,false,true) end, - everysecond = wave[8].everysecond, - conditions = wave[8].conditions + everysecond = wave[6].everysecond, + conditions = wave[6].conditions, + boss = true } wave[13] = { @@ -191,7 +188,7 @@ wave[13] = { addbomb(128,46, 0) addlasershooter(128, 90, 50, 0.1, false) end, - everysecond = wave[8].everysecond, + everysecond = wave[6].everysecond, } wave[14] = { @@ -207,14 +204,41 @@ wave[14] = { wave[15] = { delay = 0, + start = function() + for i = 1, 6, 1 do + addtargetingenemy(128, i*16-14+flr(i/4)*36, 0.05) + end + addbomb(140,46, 1) + end +} + +wave[16] = { + delay = 0, + start = function() + addwallboss(128, 2, 7, 30, 0.05, false, 3, false) + addwallboss(128, 70, 7, 30, 0.05, false, 3, false) + end, + everysecond = function () + if flr(currentwavetime%6) == 5 and currentwavetime < 20 then + local y = 16 + if players[1].y > 64 then + y = 80 + end + addlasershooter(128, y, 50, 0.1, false) + end + end +} + +wave[17] = { + delay = 0, start = wave[5].start, everysecond = function() if currentwavetime%5 > 4 and currentwavetime < 20 then addbomb(128,20+currentwavetime*2,0) end - if currentwavetime > 18 and not changedmusic then + if currentwavetime > 18 and not bossmusic then music(8, 0, 3) - changedmusic = true + bossmusic = true end addbasicenemy(128,rnd(100)+14,0.4+rnd(0.4)) end, @@ -224,7 +248,7 @@ wave[15] = { end } -wave[16] = { +wave[18] = { delay = 0, start = function() for i = 1, #enemies, 1 do @@ -232,23 +256,21 @@ wave[16] = { end addmissileboss(128, 0) end, - everysecond = wave[8].everysecond, + everysecond = wave[6].everysecond, + conditions = wave[6].conditions, + boss = true } -wave[17] = { - delay = 0, +wave[19] = { + delay = 7, start = function() addfinalboss() - addballshooter(128, 56, 0.1) end, - everysecond = function() - local y = rnd(30)+50 - addbasicenemy(115,y,0.4+rnd(0.4)) - end + boss = true } --ending score screen -wave[18] = { +wave[20] = { delay = 3, start = function() if #players == 1 then @@ -258,12 +280,9 @@ wave[18] = { end end, conditions = function() - end + end } ---wave[currentwave].start() ---music(0, 0, 3) - foreach(wave, function(wave) if not wave.conditions then wave.conditions = function() if #enemies < 1 then return true end end end end) --if there are no conditons for a wave, give them one. look at all those ends!!!! function updatewaves() @@ -276,14 +295,18 @@ function updatewaves() end end if wave[currentwave].conditions() then + if wave[currentwave+1].boss and not bossmusic then + bossmusic = true + music(8,0,3) + end delaytimer += ft if delaytimer > wave[min(currentwave+1, #wave)].delay then - if changedmusic and currentwave ~= 15 then - music(0, 0, 3) - changedmusic = false - end everysecondtimer = 0 currentwave += 1 + if not wave[currentwave].boss and bossmusic then + music(2,0,3) + bossmusic = false + end currentwavetime = 0 delaytimer = 0 -- currentwave = (currentwave - 1) % #wave+1 --temporarily looping the waves @@ -301,7 +324,5 @@ function setwave(num) currentwavetime = 0 delaytimer = 0 wave[currentwave].start() - if changedmusic then - music(0, 0, 3) - end + music(2, 0, 3) end
\ No newline at end of file |
