aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bullets.lua97
-rw-r--r--enemies.lua53
-rw-r--r--particles.lua10
-rw-r--r--pickups.lua42
-rw-r--r--players.lua30
-rw-r--r--test.p8.pngbin0 -> 39405 bytes
-rw-r--r--waves.lua60
7 files changed, 127 insertions, 165 deletions
diff --git a/bullets.lua b/bullets.lua
index a758f02..1b217e7 100644
--- a/bullets.lua
+++ b/bullets.lua
@@ -1,26 +1,23 @@
-function addbullet(x, y, velx, vely, evil, sprite)
+function addbullet(x, y, velx, vely, good, sprite)
local bullet = {
- sprite = sprite or 2,
- evil = evil,
- x = x,
- y = y,
- velx = velx,
- vely = vely,
}
+ sprite = sprite or 2
+ good = good or false
+
function bullet.draw(bullet)
- spr(bullet.sprite, bullet.x, bullet.y)
+ spr(sprite, x, y)
end
function bullet.collide(object)
- if bullet.x+4 >= object.x and bullet.x+4 <= object.x+object.w and bullet.y+4 >= object.y and bullet.y+4 <= object.y+object.h and object.inv < 0 then
+ if x+4 >= object.x and x+4 <= object.x+object.w and y+4 >= object.y and y+4 <= object.y+object.h and object.inv < 0 then
object:shot()
del(obj, bullet)
end
end
function bullet.accurate_collide(object)
- if bullet.x+4 >= object.x-2 and bullet.x+4 <= object.x+2+object.w and bullet.y+4 >= object.y-2 and bullet.y+4 <= object.y+object.h+2 then
+ if x+4 >= object.x-2 and x+4 <= object.x+2+object.w and y+4 >= object.y-2 and y+4 <= object.y+object.h+2 then
object:shot()
del(obj, bullet)
end
@@ -28,18 +25,18 @@ function addbullet(x, y, velx, vely, evil, sprite)
function bullet.update(bullet)
--applying velocity
- bullet.x += bullet.velx
- bullet.y += bullet.vely
+ x += velx
+ y += vely
--collision detection
- if bullet.evil then
- foreach(players, bullet.collide)
- elseif bullet.evil == false then
+ if good then
foreach(enemies, bullet.accurate_collide)
+ else
+ foreach(players, bullet.collide)
end
--delete bullet if off screen
- if bullet.y > 128 or bullet.y < -8 or bullet.x > 128 or bullet.x < -8 then
+ if y > 128 or y < -8 or x > 128 or x < -8 then
del(obj, bullet)
end
end
@@ -51,61 +48,61 @@ end
function addlaser(x, y, r)
local laser = {
--lasers!!!!!!!!!!!!!!!
- x = x,
- y = y,
- r = r,
- timer = 0,
- playingsound = false
}
-
- function laser.draw(laser)
- if laser.timer > 1.5 then
- local radius = (min(laser.timer*laser.r*0.7,laser.r)+sin(t()*6))-mid(0, laser.timer-3, laser.r)*laser.r
- for i = -10, laser.x, 1 do
- line(i, laser.y+radius*sin(t()*3+i/(10+laser.timer^3.5))*1.6, i, laser.y-radius*sin(t()*3+i/(10+laser.timer^3.5))*1.6, 14)
- pset(i, laser.y+(cos(t()*1.5+i/50)+sin(i/4.32535+t())*2)*radius/1.8, 14)
+ timer = 0
+ 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)
+ pset(i, y+(cos(t()+i/50)+sin(i/4.32535+t())*2)*radius/1.8, 14)
end
- circfill(laser.x, laser.y, radius, 14)
- rectfill(-10, laser.y-radius, laser.x, laser.y+radius, 14)
- circfill(laser.x, laser.y, radius*0.7, 11)
- rectfill(-10, laser.y-radius*0.7, laser.x, laser.y+radius*0.7, 11)
- circfill(laser.x, laser.y, radius*0.3, 7)
- rectfill(-10, laser.y-radius*0.3, laser.x, laser.y+radius*0.3, 7)
+ --circfill(x, y, radius, 14)
+ --rectfill(-10, y-radius, x, y+radius, 14)
+ circfill(x, y, radius*0.7, 11)
+ rectfill(-10, y-radius*0.7, x, y+radius*0.7, 11)
+ circfill(x, y, radius*0.3, 7)
+ rectfill(-10, y-radius*0.3, x, y+radius*0.3, 7)
else
- 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/(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)
+ circfill(x, y, timer*4+sin(t()*8), 11)
+ circfill(x, y, timer*2+sin(t()*8), 7)
+ for i = mid(-5, x-timer*x,x), x, 1 do
+ pset(i, y+sin(i/(3/(timer/2))-t())*timer*r/2, 11)
+ pset(i, y+cos(t()*timer+i/30)*timer*3+sin(i/8.32535+t()), 14)
end
end
end
function laser.collide(object)
- if object.x < laser.x and laser.y+laser.r*2 > object.y+object.h and laser.y-laser.r*2 < object.y and object.inv < 0 then
+ --local _ENV = laser
+ if object.x < x and y+r*2 > object.y+object.h and y-r*2 < object.y and object.inv < 0 then
object:shot()
end
end
function laser.update(laser)
- laser.timer += 1/60
+ timer += 1/60
--collision detection after the warm up
- if laser.timer > 1.5 and laser.timer < 3.6 then
- if not laser.playingsound then
+ if timer > 1.5 and timer < 3.6 then
+ if not playingsound then
sfx(24,3)
- laser.playingsound = true
+ playingsound = true
end
- shake = rnd(8)/laser.timer
+ shake = rnd(8)/timer
foreach(players, laser.collide)
foreach(enemies, laser.collide)
end
--delete laser once its done
- if laser.timer > 4 then
+ if timer > 4 then
del(obj, laser)
sfx(25, 3)
for i = 1, 16, 1 do
- addcircle(rnd(laser.x), laser.y-laser.r/2+rnd(laser.r), -0.5, -0.5, rnd(3), rnd(2), rnd({11,14,3}), 0)
+ addcircle(rnd(x), y-r/2+rnd(r), -0.5, -0.5, rnd(3), rnd(2), rnd({11,14,3}))
end
end
end
@@ -117,7 +114,7 @@ end
function addmissile(x, y, target) --basic small weak enemy
local enemy = {
- target = target,
+ --target = target,
x = x,
y = y,
w = 16,
@@ -139,8 +136,8 @@ function addmissile(x, y, target) --basic small weak enemy
function enemy.update()
enemy.x -= enemy.speed
enemy.speed += 0.015
- enemy.y += (players[enemy.target].y - enemy.y)/30
- addcircle(enemy.x+12, enemy.y+rnd(8), 0, rnd()/8, 2.1, 0.6, rnd({9,5}), 0)
+ enemy.y += (players[target].y - enemy.y)/30
+ addcircle(enemy.x+12, enemy.y+rnd(8), 0, rnd()/8, 2.1, 0.6, rnd({9,5}))
enemymisc(enemy)
if enemy.health <= 0 then -- die!!!!!
enemydie(enemy,17,2)
diff --git a/enemies.lua b/enemies.lua
index 4477cfe..d905152 100644
--- a/enemies.lua
+++ b/enemies.lua
@@ -15,10 +15,12 @@ function enemyshot(enemy)
end
function enemycollide(enemy, object) --f this enemy collides with something, do damage to both it and itself. also EXPLODE!!!
- if enemy.x <= object.x+object.w and enemy.x+enemy.w >= object.x and enemy.y <= object.y +object.h and enemy.y+enemy.h >= object.y and object.inv < 0 then
+ local rnd,explosion = rnd,explosion
+ local _ENV = enemy --trying to save tokens?
+ if x <= object.x+object.w and x+w >= object.x and y <= object.y +object.h and y+h >= object.y and object.inv < 0 then
object:shot()
- explosion(enemy.x+4+rnd(enemy.w-4), enemy.y+4*rnd(enemy.h-4))
- enemy.health -= 2
+ explosion(x+4+rnd(w-4), y+4*rnd(h-4))
+ health -= 2
end
end
@@ -85,7 +87,7 @@ function addbasicenemy(x, y, speed) --basic small weak enemy
if enemy.shootcooldown < 0 then
enemy.shootcooldown = 0.5 + rnd(1.5)
if enemy.x < 124 and enemy.x > 5 then
- addbullet(enemy.x-3, enemy.y, -1, 0, true, 2) -- shoot if on screen
+ addbullet(enemy.x-3, enemy.y, -1, 0) -- shoot if on screen
sfx(15, 2) -- play shoot sound if on screen
end
end
@@ -139,7 +141,7 @@ function addwallshooter(x, shootup, health, speed, offset, bulletspeed)
local vely = -1
if shootup then vely = 1 end
if enemy.x < 120 and enemy.x > 20 then
- addbullet(enemy.x, enemy.y, -enemy.speed, enemy.bulletspeed*vely, true, 2)
+ addbullet(enemy.x, enemy.y, -enemy.speed, enemy.bulletspeed*vely)
if not enemy.shoottoggle then --implemented a toggle so that the sound effect for firing gets played only once.
enemy.shoottoggle = true
sfx(18, 3)
@@ -194,7 +196,7 @@ function addballshooter(x, y, speed)
if enemy.x < 126 and enemy.x > 0 then
for i = 1, 48, 1 do --shoot ring of bullets if on screen
if sin(i/48) < 0.3 and sin((i+currentwavetime)/8) < 0.4 then
- addbullet(enemy.x+4, enemy.y+4, sin(i/48)/2, cos(i/48)/2, true, 2)
+ addbullet(enemy.x+4, enemy.y+4, sin(i/48)/2, cos(i/48)/2)
end
end
sfx(19, 3) -- play shoot sound
@@ -243,7 +245,7 @@ function addtargetingenemy(x, y, speed)
local distance = sqrt((players[p].x - enemy.x)^2+(players[p].y - enemy.y)^2)
local velx = (players[p].x - enemy.x)/distance
local vely = (players[p].y - enemy.y)/distance
- addbullet(enemy.x-3, enemy.y, velx, vely, true, 2) -- shoot if on screen
+ addbullet(enemy.x-3, enemy.y, velx, vely) -- shoot if on screen
sfx(15, 2) -- play shoot sound if on screen
end
end
@@ -276,7 +278,7 @@ function addlasershooter(x, y, speed, stay)
}
if stay then enemy.y = 64-20 end
- function enemy.draw(enemy)
+ function enemy:draw()
if enemy.inv < 0 or ceil(enemy.inv*10%2) == 1 then
local sprite = 64
if enemy.health < 10 then
@@ -302,7 +304,7 @@ function addlasershooter(x, y, speed, stay)
enemy.y = 64-20 + sin(enemy.moveoffset+enemy.lasertimer/enemy.sinspeed) * 40
if enemy.shootcooldown < 0 then
enemy.shootcooldown = 0.18
- addbullet(enemy.x+6, enemy.y+20, -1, rnd(2)-1, true, 2) --shoooot!!!!!
+ addbullet(enemy.x+6, enemy.y+20, -1, rnd(2)-1) --shoooot!!!!!
sfx(15, 2)
end
end
@@ -352,7 +354,7 @@ function addwallboss(x, y, length, speed, stay, move)
w = 16,
h = 8*length,
inv = -1,
- health = 1*length*#players, --10
+ health = 10*length*#players, --10
shootcooldown = 3,
speed = speed,
bulletfired = {},
@@ -422,9 +424,7 @@ function addwallboss(x, y, length, speed, stay, move)
for i = 1, length, 1 do
if attack(i, enemy.move) then
- local bulletspeed = -1-rnd(0.2)
- if enemy.move > 2 then bulletspeed = -1 end
- addbullet(enemy.x, enemy.y-8+i*8, bulletspeed, 0, true, 2)
+ addbullet(enemy.x, enemy.y-8+i*8, -1, 0)
sfx(15, 2)
enemy.bulletfired[i] = 1
else
@@ -477,24 +477,31 @@ function addbomb(x, y, delay) --BIG BOMB!!!! KILL IIT QUICKLY!!!!
end
function enemy.update()
- if enemy.shootcooldown < 0 then
- enemy.x = enemy.x + 0.02 * (80 - enemy.x);
- end
enemy.y += sin(time()/3)/8
if enemy.shootcooldown < -8 then -- detonation
for i = 1, 60, 1 do
- addbullet(enemy.x+16, enemy.y+16, sin(i/60), cos(i/60), true, 2)
+ addbullet(enemy.x+16, enemy.y+16, sin(i/60), cos(i/60))
enemy.health = 0
sfx(19,2)
+ sfx(8,-2)
end
+ elseif enemy.shootcooldown < 0 then
+ enemy.x = enemy.x + 0.02 * (80 - enemy.x);
end
enemymisc(enemy)
if enemy.health <= 0 then -- die!!!!!
enemydie(enemy,20,3)
end
+ --charge sound
+ if enemy.x < 120 and everysecondtimer > 0.45 then
+ if enemy.shootcooldown < -5 then
+ sfx(8,2) --rapid
+ else
+ sfx(7,2) --normal
+ end
+ end
end
- sfx(62,3) --charge
add(enemies, enemy)
end
@@ -518,7 +525,7 @@ function addmissileboss(x, y) --boss that shoots missiles!!!
function enemy.draw(enemy)
local sprite = 68
- if enemy.health < 21 then
+ if enemy.health < 11 then
sprite = 100
damagesmoke(enemy)
end
@@ -528,7 +535,7 @@ function addmissileboss(x, y) --boss that shoots missiles!!!
end
end
- function enemy.update()
+ function enemy.update(enemy)
local playertarget = ceil((t()/2.4)%#players)
enemy.targetchangetimer -= 1/60
--some cool different moves, shout out to dont get a virus fans!
@@ -548,13 +555,13 @@ function addmissileboss(x, y) --boss that shoots missiles!!!
end
if enemy.shootcooldown < 0 then
enemy.shootcooldown = 0.3 + rnd(1.2)
- if enemy.x < 129 then
+ if enemy.x < 122 and players[playertarget] ~= nil then
local offset = 2
if currentwavetime%2 > 1 then offset = 30 end
addmissile(enemy.x, enemy.y+offset, playertarget)
- if enemy.health < 12 then
+ if enemy.health < 11 then
sfx(15, 2)
- addbullet(enemy.x,enemy.y+16,(players[playertarget].x-enemy.x)/70,(players[playertarget].y-enemy.y-16)/70,true)
+ addbullet(enemy.x,enemy.y+16,(players[playertarget].x-enemy.x)/70,(players[playertarget].y-enemy.y-16)/70)
-- ERROR attempting to find a non existant player
end
enemy.speed += 0.001
diff --git a/particles.lua b/particles.lua
index 72e090f..9f6d558 100644
--- a/particles.lua
+++ b/particles.lua
@@ -9,7 +9,7 @@ function addcircle(x, y, velx, vely, r, time, color, grav)
time = time,
t = time,
col = color,
- grav = grav
+ grav = grav or 0
}
function circle.draw(circle)
@@ -33,17 +33,17 @@ function explosion(x,y, w, h)
w = w or 8
h = h or 8
for i = 1, w/2, 1 do
- addcircle(x+rnd(w), y+rnd(h), -0.5, 0, rnd(8), rnd(1.5)+1, 5, 0)
+ addcircle(x+rnd(w), y+rnd(h), -0.5, 0, rnd(8), rnd(1.5)+1, 5)
end
for i = 1, w/2, 1 do
- addcircle(x+rnd(w), y+rnd(h), -0.4, 0, rnd(8), rnd(1)+0.5, 9, 0)
+ addcircle(x+rnd(w), y+rnd(h), -0.4, 0, rnd(8), rnd(1)+0.5, 9)
end
end
function damagesmoke(object)
--smokes when damaged!
- addcircle(object.x+rnd(object.w*0.5), object.y+rnd(object.w*0.5), -0.5, -0.2, rnd(6), rnd(1.5)+1, 5, 0)
+ addcircle(object.x+rnd(object.w*0.5), object.y+rnd(object.w*0.5), -0.5, -0.2, rnd(6), rnd(1.5)+1, 5)
if ceil(rnd(2)) == 1 then
- addcircle(object.x+rnd(object.w*0.5), object.y+rnd(object.w*0.5), -0.4, -0.2, rnd(6), rnd(1)+0.5, 9, 0)
+ addcircle(object.x+rnd(object.w*0.5), object.y+rnd(object.w*0.5), -0.4, -0.2, rnd(6), rnd(1)+0.5, 9)
end
end \ No newline at end of file
diff --git a/pickups.lua b/pickups.lua
index 6e4a103..0b259cd 100644
--- a/pickups.lua
+++ b/pickups.lua
@@ -15,53 +15,53 @@ add(obj, randompickups)
function addpickup(x, y, type)
local pickup = {}
- pickup.x = x
- pickup.y = y
- pickup.type = type or rnd({"health", "health", "fastshoot", "3shoot"})
- pickup.sprite = 4
+ x = x
+ y = y
+ type = type or rnd({"health", "health", "fastshoot", "3shoot"})
+ sprite = 4
- if (pickup.type == "fastshoot") then
- pickup.sprite = 20
- elseif (pickup.type == "3shoot") then
- pickup.sprite = 36
+ if type == "fastshoot" then
+ sprite = 20
+ elseif type == "3shoot" then
+ sprite = 36
end
function pickup.collide(player)
- if pickup.x+4 >= player.x-4 and pickup.x+4 <= player.x+4+player.w and pickup.y+4 >= player.y-4 and pickup.y+4 <= player.y+player.h+4 and player.health > 0 then
+ 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 (pickup.type == "fastshoot") then
+ if type == "fastshoot" then
color = 12
- elseif (pickup.type == "3shoot") then
+ elseif type == "3shoot" then
color = 9
end
- addcircle(pickup.x, pickup.y, sin(i/8), cos(i/8), 2, 0.6, color, 0)
+ addcircle(x, y, sin(i/8), cos(i/8), 2, 0.6, color)
end
del(obj, pickup)
end
end
- function pickup.affect(pickup, player)
- if pickup.type == "health" then
+ function pickup:affect(player)
+ if type == "health" then
player.health = 3
- elseif pickup.type == "fastshoot" then
+ elseif type == "fastshoot" then
player.shootspeed = 0.1
- elseif pickup.type == "3shoot" then
+ elseif type == "3shoot" then
player.shoot3 = true
end
sfx(30, 1)
end
function pickup.draw(pickup)
- spr(pickup.sprite, pickup.x, pickup.y)
+ spr(sprite, x, y)
end
function pickup.update(pickup)
- pickup.x -= 0.3
- pickup.y += sin(time()/2)*0.2
+ x -= 0.3
+ y += sin(time()/2)*0.2
foreach(players, pickup.collide)
- if pickup.x < -8 then
+ if x < -8 then
del(obj, pickup)
end
end
@@ -69,4 +69,4 @@ function addpickup(x, y, type)
add(obj, pickup)
end
--- addpickup(120, 60) \ No newline at end of file
+ --addpickup(120, 60) \ No newline at end of file
diff --git a/players.lua b/players.lua
index 608fb08..9f05676 100644
--- a/players.lua
+++ b/players.lua
@@ -8,8 +8,8 @@ function addplayer(x, y, sprite, bulletsprite)
y = y,
w = 8,
h = 8,
- sprite = sprite,
- bulletsprite = bulletsprite,
+ --sprite = sprite,
+ --bulletsprite = bulletsprite,
ymov = 0,
inv = 2,
id = #players,
@@ -19,22 +19,22 @@ function addplayer(x, y, sprite, bulletsprite)
shoot3 = false
}
- function player.draw(player)
+ function player:draw()
-- print(player.health)
--draw a different sprite when moving, and blink when hurt
if (player.inv < 0 or ceil(player.inv*10%2) == 1) and player.health > 0 then
if (player.ymov == 0) then
- spr(player.sprite, player.x, player.y)
+ spr(sprite, player.x, player.y)
elseif (player.ymov == 1) then
- spr(player.sprite+1, player.x, player.y)
+ spr(sprite+1, player.x, player.y)
elseif (player.ymov == -1) then
- spr(player.sprite+1, player.x, player.y, 1, 1, false, true)
+ spr(sprite+1, player.x, player.y, 1, 1, false, true)
end
end
end
- function player.shot(player)
+ function player.shot()
--when the player is shot, reduce health and make temporarily invincible
--also remove any powerups, shake the screen, and spawn an explosion.
player.health -= 1
@@ -59,11 +59,11 @@ function addplayer(x, y, sprite, bulletsprite)
end
end
- function player.respawn(player)
+ function player.respawn()
player.health = 3
player.inv = 3
for i = 1, 8, 1 do
- addcircle(player.x+4, player.y+4, sin(i/8), cos(i/8), 2, 0.6, 7, 0)
+ 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
@@ -73,7 +73,7 @@ function addplayer(x, y, sprite, bulletsprite)
end
end
- function player.update(player)
+ function player:update()
--movement
if player.health > 0 then -- can only input if alive!!!
if btn(0, player.id) then
@@ -97,8 +97,8 @@ function addplayer(x, y, sprite, bulletsprite)
--particles from rockets, and smoke/sparks from damage
player.particlecooldown -= 1/60
if player.particlecooldown < 0 and player.health > 0 then
- addcircle(player.x-1, player.y, -0.5, 0, 1.5, 0.5, 9, 0)
- addcircle(player.x-1, player.y+7, -0.5, 0, 1.5, 0.5, 9, 0)
+ addcircle(player.x-1, player.y, -0.5, 0, 1.5, 0.5, 9)
+ addcircle(player.x-1, player.y+7, -0.5, 0, 1.5, 0.5, 9)
if player.health < 3 then
addcircle(player.x+rnd(8), player.y+rnd(8), rnd(1.5)-0.75, -1.5, 1, rnd(1)+0.5, 9, -0.1)
if player.health < 2 then
@@ -115,10 +115,10 @@ function addplayer(x, y, sprite, bulletsprite)
--for i = 1, 4, 1 do
--addcircle(player.x+3, player.y+4, rnd(1)+0.5, rnd(1)-0.5, 1.5, rnd(0.4), 12)
--end
- addbullet(player.x+3, player.y, 2, 0, false, player.bulletsprite)
+ addbullet(player.x+3, player.y, 2, 0, true, bulletsprite)
if player.shoot3 then
- addbullet(player.x+3, player.y+3, 2, 0.25, false, player.bulletsprite)
- addbullet(player.x+3, player.y-3, 2, -0.25, false, player.bulletsprite)
+ addbullet(player.x+3, player.y+3, 2, 0.25, true, bulletsprite)
+ addbullet(player.x+3, player.y-3, 2, -0.25, true, bulletsprite)
sfx(12, 2)
else
sfx(9, 2)
diff --git a/test.p8.png b/test.p8.png
new file mode 100644
index 0000000..46c1565
--- /dev/null
+++ b/test.p8.png
Binary files differ
diff --git a/waves.lua b/waves.lua
index f3c26a0..c196d85 100644
--- a/waves.lua
+++ b/waves.lua
@@ -1,5 +1,5 @@
wave = {} --store wave functions here
-currentwave = 1 --THIS IS THE CURRENT WAVE, SHOLD BE 1 UNLESS TESTING SOMETHING
+currentwave = 8 --THIS IS THE CURRENT WAVE, SHOLD BE 1 UNLESS TESTING SOMETHING
currentwavetime = 0
delaytimer = 0
everysecondtimer = 0
@@ -11,14 +11,12 @@ wave[1] = {
start = function()
addbasicenemy(150, 60, 0.15)
end,
- everysecond = function()
- end,
- conditions = function()
- if #enemies < 1 then return true
- end
- end
}
+for i = 2, 16, 1 do
+ wave[i] = {}
+end
+
wave[2] = {
delay = 2,
start = function()
@@ -26,8 +24,6 @@ wave[2] = {
addtargetingenemy(128, 60, 0.1)
addbasicenemy(128, 90, 0.4)
end,
- everysecond = function()
- end,
conditions = function()
if #enemies < 2 then return true
end
@@ -42,8 +38,6 @@ wave[3] = {
addbasicenemy(170, i*16, 1.05 - 0.075*i)
end
end,
- everysecond = function()
- end,
conditions = function()
if #enemies < 5 then return true
end
@@ -58,8 +52,6 @@ wave[4] = {
addtargetingenemy(155, 60, 0.15)
addbasicenemy(128, 90, 0.5)
end,
- everysecond = function()
- end,
conditions = function()
if #enemies < 2 then return true
end
@@ -94,12 +86,6 @@ wave[6] = {
addballshooter(160, 14, 0.1)
addballshooter(160, 100, 0.1)
end,
- everysecond = function()
- end,
- conditions = function()
- if #enemies < 1 then return true
- end
- end
}
wave[7] = {
@@ -113,12 +99,6 @@ wave[7] = {
addbasicenemy(140, 30, 0.2)
addbasicenemy(140, 110, 0.2)
end,
- everysecond = function()
- end,
- conditions = function()
- if #enemies < 1 then return true
- end
- end
}
wave[8] = {
@@ -156,8 +136,6 @@ wave[9] = {
addwallshooter(230, true, 10, 0.4)
addballshooter(230, 56, 0.2)
end,
- everysecond = function()
- end,
conditions = function()
if #enemies < 2 then return true
end
@@ -171,8 +149,6 @@ wave[10] = {
addtargetingenemy(128, i*16-4, 0.1)
end
end,
- everysecond = function()
- end,
conditions = function()
if #enemies < 2 then return true
end
@@ -188,12 +164,6 @@ wave[11] = {
end
addballshooter(200, 56, 0.2)
end,
- everysecond = function()
- end,
- conditions = function()
- if #enemies < 1 then return true
- end
- end
}
wave[12] = {
@@ -218,10 +188,6 @@ wave[13] = {
addlasershooter(128, 128-38, 0.1, false)
end,
everysecond = wave[8].everysecond,
- conditions = function()
- if #enemies < 1 then return true
- end
- end
}
wave[14] = {
@@ -233,12 +199,6 @@ wave[14] = {
addballshooter(128, 14, 0.03)
addballshooter(128, 100, 0.03)
end,
- everysecond = function()
- end,
- conditions = function()
- if #enemies < 1 then return true
- end
- end
}
wave[15] = {
@@ -269,10 +229,6 @@ wave[16] = {
addmissileboss(128, 0)
end,
everysecond = wave[8].everysecond,
- conditions = function()
- if #enemies < 1 then return true
- end
- end
}
--wave[currentwave].start()
@@ -283,9 +239,11 @@ function updatewaves()
everysecondtimer += 1/60
if everysecondtimer >= 1 then
everysecondtimer = 0
- wave[currentwave].everysecond()
+ if wave[currentwave].everysecond then
+ wave[currentwave].everysecond()
+ end
end
- if wave[currentwave].conditions() then
+ if (wave[currentwave].conditions and wave[currentwave].conditions() or #enemies < 1) then
delaytimer += 1/60
if delaytimer > wave[min(currentwave+1, #wave)].delay then
if changedmusic and currentwave ~= 15 then