aboutsummaryrefslogtreecommitdiff
path: root/players.lua
diff options
context:
space:
mode:
Diffstat (limited to 'players.lua')
-rw-r--r--players.lua30
1 files changed, 15 insertions, 15 deletions
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)