aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bullets.lua3
-rw-r--r--draw.lua6
-rw-r--r--enemies.lua75
-rw-r--r--objects.lua15
-rw-r--r--particles.lua5
-rw-r--r--pickups.lua2
-rw-r--r--update.lua12
-rw-r--r--waves.lua51
8 files changed, 87 insertions, 82 deletions
diff --git a/bullets.lua b/bullets.lua
index 715a1ee..c5cf2c7 100644
--- a/bullets.lua
+++ b/bullets.lua
@@ -141,6 +141,9 @@ function addmissile(x, y, target) --basic small weak enemy
enemymisc(enemy)
if enemy.health <= 0 then -- die!!!!!
enemydie(enemy,17,2,17)
+ if currentwave == 19 then
+ sfx(14,-2)
+ end
end
end
diff --git a/draw.lua b/draw.lua
index 7648cda..9beb927 100644
--- a/draw.lua
+++ b/draw.lua
@@ -39,11 +39,11 @@ if not gamerunning or menuscroll < 1 then
for i = 1, 3, 1 do
spr(14+i*16, (-menushipscroll*(i*20)+(sin(i/3)*128)+8)%(128+8)-1*8-menuscroll*240, i*36+sin(menushipscroll*i/3)*i*2-20-menuscroll*50,1,1)
end
-
+ local x = 24-menuscroll*120
if t() < 1 then
- drawlogo(24-menuscroll*120,19.5+sin(0.25+t()*0.5)*6.5)
+ drawlogo(x,19.5+sin(0.25+t()*0.5)*6.5)
else
- drawlogo(24-menuscroll*120,26)
+ drawlogo(x,26)
end
--main screen items
diff --git a/enemies.lua b/enemies.lua
index 942ab65..0874647 100644
--- a/enemies.lua
+++ b/enemies.lua
@@ -1,5 +1,5 @@
enemies = {}
-canshootatx = 126
+canshootatx = 126 --the point on screen when they can start shooting. this needs to be a thing for the final boss portal
function killallenemies()
for i = 1, #enemies, 1 do
enemies[i].health = -1
@@ -26,21 +26,22 @@ function enemycollide(enemy, object) --f this enemy collides with something, do
end
end
-function enemydie(enemy, sound, soundchannel, points, isboss)
+function enemydie(enemy, sound, soundchannel, points, isboss, drop)
+ --the drop option is a stupid hack, only the final boss gets to use it.
if enemy.health < 1 then --no health? die.
local x,y = enemy.x,enemy.y
for i = 1, rnd(enemy.h)+6, 1 do
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
+ if rnd(100) < sqrt(enemy.w*enemy.h)/1.5 and not drop then --you get a better chance of a randomly dropped health from bigger enemies
addpickup(x+rnd(enemy.w), y+rnd(enemy.h), "health")
end
if isboss then
- music(-1, 3000)
+ playsong(-1, 3000)
sfx(60,-2) --stop missle sound, less tokens to just have it here.
despawnallbullets = true
killallenemies()
- if not gameover then
+ if not gameover and not drop then
addpickup(x+rnd(32), y+rnd(32))
addpickup(x+rnd(32), y+rnd(32), "health")
end
@@ -245,10 +246,11 @@ function addtargetingenemy(x, y, speed)
enemy.x -= speed
if enemy.shootcooldown < 0 and currentwavetime%1.5>1.2 then
enemy.shootcooldown = 0.1
- if enemy.x < canshootatx and players[targetplayer].x < enemy.x+30 then --math involving a distance check to get the proper velocity for aiming
- local distancetarget = sqrt((players[targetplayer].x - enemy.x)^2+(players[targetplayer].y - enemy.y)^2)
- local velxtarget = (players[targetplayer].x - enemy.x)/distancetarget
- local velytarget = (players[targetplayer].y - enemy.y)/distancetarget
+ local player = players[targetplayer]
+ if enemy.x < canshootatx and player.x < enemy.x+30 then --math involving a distance check to get the proper velocity for aiming
+ local distancetarget = sqrt((player.x - enemy.x)^2+(player.y - enemy.y)^2)
+ local velxtarget = (player.x - enemy.x)/distancetarget
+ local velytarget = (player.y - enemy.y)/distancetarget
addbullet(enemy.x-3, enemy.y, velxtarget, velytarget) -- shoot if on screen
sfx(15, 2) -- play shoot sound if on screen
end
@@ -355,7 +357,7 @@ function addwallboss(x, y, length, points, speed, stay, move, isboss)
}
bulletfired = {}
enemy.starthealth = enemy.health
- if isboss then enemy.health *= 3 end -- triple health if the boss
+ if isboss then enemy.health *= 4 end -- triple health if the boss
for i = 1, length, 1 do
bulletfired[i] = 0
@@ -534,7 +536,7 @@ function addmissileboss(x, y) --boss that shoots missiles!!!
elseif currentwavetime%18 > 17.3 then --INTIMIDATION TACTICS!!!!!
enemy.targety = players[targetplayer].y
enemy.targetx = players[targetplayer].x+24
- enemy.shootcooldown = 0.4
+ enemy.shootcooldown = 0.8
end
enemy.x = lerp(enemy.x, enemy.targetx, enemy.speed)
enemy.y = lerp(enemy.y, enemy.targety, enemy.speed)
@@ -544,7 +546,7 @@ function addmissileboss(x, y) --boss that shoots missiles!!!
enemy.targety = rnd(96)
end
if enemy.shootcooldown < 0 then
- enemy.shootcooldown = 0.3 + rnd(1.2)
+ enemy.shootcooldown = 0.6 + rnd(0.5)
if enemy.x < canshootatx and players[targetplayer] ~= nil then
local offsetmissleboss = 2
if currentwavetime%2 > 1 then offsetmissleboss = 30 end
@@ -567,19 +569,20 @@ end
function addfinalboss() --THE FINAL BOSS!!!!!!! WOOOAAAHHHHHH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
local enemy = {
x = 150,
- y = 10,
+ y = 30,
w = 32,
- h = 120,
+ h = 66,
inv = -1,
health = 200*#players, --200
shootcooldown = 4,
shot = enemyshot,
collide = enemycollide,
- speed = 1.5,
- amount = 3,
}
dramaticdeathtimer = 6
thrusterexplode = {}
+ portaldestabilize = 0
+ speed = 1.5
+ amount = 3
--thrusters that each fall off once the portal's health is 1/5th depleated
function addportalthruster(x,y,id,isflipped)
@@ -591,32 +594,33 @@ function addfinalboss() --THE FINAL BOSS!!!!!!! WOOOAAAHHHHHH!!!!!!!!!!!!!!!!!!!
if thrusterhealth > enemy.health - 20 then
spritethruster += 32
end
- if (enemy.inv < 0 or flashtime) or thrusterhealth < enemy.health-50 then
- spr(spritethruster, x, isflipped*(sin(time()*enemy.speed)*3.5)+y, 4, 2)
- end
+ spr(spritethruster, x, isflipped*(sin(time()*speed)*3.5)+y, 4, 2)
elseif rnd() < 0.4 then
addcircle(x+20+rnd(4), y+rnd(6), -0.5, rnd(0.5)-0.25, rnd(7), 1.4, rnd({5,9}))
if not thrusterexplode[id] then
thrusterexplode[id] = true
explosion(x+10,y,32)
shake = 12
+ sfx(21,3)
end
end
end
function enemy:draw()
- -- portal
- local x,y,speed,amount = enemy.x-8,10+sin(time()*enemy.speed+0.2)*2,enemy.speed,enemy.amount
- local ovaly1 = (sin(time()*speed-0.12)*amount/2)+y+24
- --local ovaly2 = (-sin(time()*speed-0.12)*amount/2)+y+84
- local ovaly2 = -ovaly1+128
- ovalfill(x+28,ovaly1,x+6,ovaly2,14)
- local portalcolors = {11,3}
- for i = 1, 260, 1 do --cool swirling portal effect
- pset(x+17+sin(i/53.3465+t()/8)*i/24+sin(i/350.23548+t()), y+54+cos(i/53.3465+t()/8)*i/9,portalcolors[(ceil(i/20))%#portalcolors+1])
- end
- addcircle(x+17, y+54, rnd(0.5)-0.25, rnd(1)-0.5, 5, 2, 11)
- oval(x+28,ovaly1,x+6,ovaly2,11)
+ local x,y = enemy.x-8,10+sin(time()*speed+0.2)*2
+ if flashtime or enemy.inv < 0 or enemy.health == 0 then
+ -- portal
+ local ovaly1 = (sin(time()*speed-0.12)*amount/2)+y+24+portaldestabilize
+ --local ovaly2 = (-sin(time()*speed-0.12)*amount/2)+y+84
+ local ovaly2 = -ovaly1+128-portaldestabilize
+ ovalfill(x+28,ovaly1,x+6,ovaly2,14)
+ local portalcolors = {11,3}
+ for i = 1, 260, 1 do --cool swirling portal effect
+ pset(x+17+sin(i/53.3465+t()/8)*i/24+sin(i/350.23548+t())*portaldestabilize, y+54+cos(i/53.3465+t()/8)*i/9,portalcolors[(ceil(i/20))%#portalcolors+1])
+ end
+ addcircle(x+17, y+54, rnd(0.5)-0.25, rnd(1)-0.5, 5, 2, 11)
+ oval(x+28,ovaly1,x+6,ovaly2,11)
+ end
addportalthruster(x-19,y-4,3)
addportalthruster(x-19,y+97,4,-1)
local spriteportal = 136
@@ -637,6 +641,7 @@ function addfinalboss() --THE FINAL BOSS!!!!!!! WOOOAAAHHHHHH!!!!!!!!!!!!!!!!!!!
for i = 1, 10, 1 do
addbullet(110,64, rnd(0.5)-1, rnd(2)-1)
end
+ sfx(19,3) --sound for barrage of bullets
if rnd() < 0.4 then
addmissile(110, 60, targetplayer)
end
@@ -675,12 +680,14 @@ function addfinalboss() --THE FINAL BOSS!!!!!!! WOOOAAAHHHHHH!!!!!!!!!!!!!!!!!!!
moves[flr((currentwavetime/14)%#moves+1)]()
end
end
- enemydie(enemy,17,2,1000,true) --die!!!!!!!
+ enemydie(enemy,17,2,1000,true,1) --die!!!!!!!
else
- music(-1)
+ playsong(-1)
killallenemies()
despawnallbullets = true
- enemy.speed += 0.002
+ speed += 0.0003
+ amount += 0.02
+ portaldestabilize += 0.05
dramaticdeathtimer -= ft
if enemy.shootcooldown < 0 then
enemy.shootcooldown = dramaticdeathtimer/8
diff --git a/objects.lua b/objects.lua
index 84c248c..e216b46 100644
--- a/objects.lua
+++ b/objects.lua
@@ -1,5 +1,5 @@
obj = {}
-gt = 0 -- game time
+gt = 0 -- game time, but not actually, this is only used by the background for scrolling.
ft = 1/60 --frametime
scrollspeed = 0
respawntimer = 0
@@ -13,13 +13,12 @@ cartdata("toxicinvaders_bychrisandribbon")
highscore0 = dget(0) --scores (0 is solo - 1 is coop)
highscore1 = dget(1)
currentscore = 0 --used for both gamemodes, but passed into highscore at end of game
+currentsong = -1
function startgame()
- music(0, 0, 3)
- wave[currentwave].start()
+ setwave(currentwave)
gamerunning = true
- -- print(gt,10,10)
end
function updateobjs()
@@ -38,4 +37,12 @@ end
function lerp(start, destination, amount)
return start + amount * (destination - start);
+end
+
+function playsong(song, fade)
+ fade = fade or 0
+ if song ~= currentsong then
+ music(song, fade, 3)
+ currentsong = song
+ end
end \ No newline at end of file
diff --git a/particles.lua b/particles.lua
index a07f95f..7d88045 100644
--- a/particles.lua
+++ b/particles.lua
@@ -19,12 +19,11 @@ function addcircle(x, y, velx, vely, r, time, color, grav)
end
end
- add(obj, circle)
+ add(obj, circle, 1)
end
function explosion(x,y, w, h)
- w = w or 8
- h = h or w
+ w,h = w or 8,h or w
for i = 1, w/2, 1 do
addcircle(x+rnd(w), y+rnd(h), -0.5, 0, rnd(8), rnd(1.5)+1, 5)
end
diff --git a/pickups.lua b/pickups.lua
index 0f21f26..40d1b75 100644
--- a/pickups.lua
+++ b/pickups.lua
@@ -43,7 +43,7 @@ function addpickup(x, y, type)
pickupcolor = 12
elseif type == "3shoot" then
player.shoot3 = true
- player.shootspeed = 0.35
+ player.shootspeed = 0.4
pickupcolor = 9
else
player.health = 3
diff --git a/update.lua b/update.lua
index 843e5ff..a527dbb 100644
--- a/update.lua
+++ b/update.lua
@@ -1,4 +1,3 @@
---scrolling and respawn stuff
respawntimer -= ft
--similar math elements grouped to lower tokens
flashtime = ceil(t()*10%2) == 1 --for flashing elements (ship, score)
@@ -7,6 +6,7 @@ circletimey = cos(t())*3
screenshakex = sin(shake+t())*shake
screenshakey = sin(shake+gt/2.1)*shake
+--stuff for scrolling background and respawning
if gameover then
scrollspeed = lerp(scrollspeed, -1/22, 0.01) -- scroll backwards
currentscore = 0 --depleats score
@@ -19,18 +19,21 @@ if gameover then
elseif gamerunning then
updatewaves() -- update the wave function
local targetspeed = ft
- if bossmusic then
+ if currentsong >= 8 then
targetspeed /= 2 --half scroll speed when boss
+ elseif currentwave == 20 then
+ targetspeed /= 8
end
scrollspeed = lerp(scrollspeed, targetspeed, 0.03)
end
gt += scrollspeed + 1/600
+--stuff for starting or ending the game
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
+ playsong(-1, 2000) --fades music
end
elseif not gamerunning and t() > 1 then --main menu
if btn(4) then
@@ -44,9 +47,10 @@ elseif not gamerunning and t() > 1 then --main menu
end
end
+--updating objects
if gamerunning or t() < 1.95 then -- weird if because of freezing bubbles in the menu
updateobjs() --update all objects
- if currentscore > 9999 then currentscore = 9999 elseif currentscore < 0 then currentscore = 0 end --attempts to avoid hitting the OOM error or being negative
+ currentscore = mid(0,currentscore,9999) --attempts to avoid hitting the OOM error or being negative
end
--screenshake math
diff --git a/waves.lua b/waves.lua
index 4daf657..29a58da 100644
--- a/waves.lua
+++ b/waves.lua
@@ -4,7 +4,6 @@ currentwavetime = 0
delaytimer = 0
everysecondtimer = 0
checkpoint = 1
-bossmusic = false
targetplayer = 1
--NOTE - slow BG during boss waves / make bosses their own checkpoint
@@ -102,7 +101,7 @@ wave[6] = {
if #enemies < 1 then checkpoint = currentwave+1 return true
end
end,
- boss = true
+ song = 8
}
wave[7] = {
@@ -170,13 +169,13 @@ wave[11] = {
}
wave[12] = {
- delay = 2,
+ delay = 3,
start = function()
addwallboss(128,4,15,225,0.05,true,false,true)
end,
everysecond = wave[6].everysecond,
conditions = wave[6].conditions,
- boss = true
+ song = 8
}
wave[13] = {
@@ -220,7 +219,7 @@ wave[16] = {
addwallboss(128, 70, 7, 30, 0.05, false, 3, false)
end,
everysecond = function ()
- if flr(currentwavetime%6) == 5 and currentwavetime < 20 then
+ if flr(currentwavetime%6) == 5 and currentwavetime < 18 then
local ylaserpos = 16
if players[targetplayer].y > 64 then
ylaserpos = 80
@@ -237,11 +236,12 @@ wave[17] = {
if currentwavetime%5 > 4 and currentwavetime < 20 then
addbomb(128,20+currentwavetime*2,0)
end
- if currentwavetime > 18 and not bossmusic then
- music(8, 0, 3)
- bossmusic = true
+ if currentwavetime > 18 then
+ playsong(8)
+ end
+ if rnd() < 0.3 then
+ addbasicenemy(128,rnd(100)+14,0.4+rnd(0.4))
end
- addbasicenemy(128,rnd(100)+14,0.4+rnd(0.4))
end,
conditions = function()
if currentwavetime > 24 then return true
@@ -255,9 +255,8 @@ wave[18] = {
killallenemies()
addmissileboss(128, 0)
end,
- everysecond = wave[6].everysecond,
conditions = wave[6].conditions,
- boss = true
+ song = 8
}
wave[19] = {
@@ -266,12 +265,12 @@ wave[19] = {
canshootatx = 110
addfinalboss()
end,
- boss = true
+ song = 8
}
--ending score screen
wave[20] = {
- delay = 3,
+ delay = 4,
start = function()
if not coopmode and highscore0 < currentscore then
dset(0, currentscore) --set singleplayer score
@@ -296,34 +295,20 @@ function updatewaves()
end
end
if wave[currentwave].conditions() then
- if wave[currentwave+1].boss and not bossmusic then
- bossmusic = true
- music(8,0,3)
+ if wave[currentwave+1].song then
+ playsong(wave[currentwave+1].song)
end
delaytimer += ft
if delaytimer > wave[currentwave+1].delay then
- 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
- -- if currentwave < checkpoint then
- -- checkpoint = 1
- -- end
- wave[currentwave].start()
+ setwave(currentwave+1)
end
end
end
function setwave(num)
- everysecondtimer = 0
currentwave = num
- currentwavetime = 0
- delaytimer = 0
+ everysecondtimer,currentwavetime,delaytimer = 0,0,0
wave[currentwave].start()
- music(2, 0, 3)
+ local song = wave[currentwave].song or 0
+ playsong(song)
end \ No newline at end of file