diff options
| author | 1029chris <1029chris@gmail.com> | 2022-02-04 16:12:11 -0800 |
|---|---|---|
| committer | 1029chris <1029chris@gmail.com> | 2022-02-04 16:12:11 -0800 |
| commit | f53f66987ade0b3f2811cacbdcf72c474170621e (patch) | |
| tree | e540e63083db6258d61a18eedc29980cc692b34f /players.lua | |
| parent | 39ecc01dba7141bce30292a38eca2f498919fb33 (diff) | |
Pickups! Camera Shake! sPARKS!! YEAHH!!!
Diffstat (limited to 'players.lua')
| -rw-r--r-- | players.lua | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/players.lua b/players.lua index ae9ee96..a4792ec 100644 --- a/players.lua +++ b/players.lua @@ -16,10 +16,12 @@ function addplayer(sprite, bulletsprite) player.id = playercount player.shootcooldown = 0.0 player.particlecooldown = 0.0 - player.type = "player" + player.shootspeed = 0.25 + player.shoot3 = false function player.draw(player) print(player.health) + --draw a different sprite when moving, and blink when hurt if player.inv < 0 or ceil(player.inv*10%2) == 1 then if (player.ymov == 0) then spr(player.sprite, player.x, player.y) @@ -32,14 +34,14 @@ function addplayer(sprite, bulletsprite) end function player.shot(player) + --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 player.inv = 1 - for i = 1, 4, 1 do - addcircle(player.x+rnd(8), player.y+rnd(8), -0.5, 0, rnd(8), rnd(1.5)+1, 5) - end - for i = 1, 4, 1 do - addcircle(player.x+rnd(8), player.y+rnd(8), -0.4, 0, rnd(8), rnd(1)+0.5, 9) - end + player.shootspeed = 0.25 + player.shoot3 = false + shake = 9 + explosion(player.x, player.y) end function player.update(player) @@ -61,18 +63,24 @@ function addplayer(sprite, bulletsprite) player.x = mid(0, player.x, 120) player.y = mid(0, player.y, 120) - --particles from rockets + --particles from rockets, and smoke/sparks from damage player.particlecooldown -= 1/60 if player.particlecooldown < 0 then - 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 == 1) then - addcircle(player.x+rnd(8), player.y+rnd(8), -0.5, -0.2, rnd(8), rnd(1.5)+1, 5) + 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) + if player.health < 3 then + addcircle(player.x+rnd(8), player.y+rnd(8), -0.5, -0.2, rnd(8), rnd(1.5)+1, 5, 0) + if player.health < 2 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 ceil(rnd(2)) == 1 then + addcircle(player.x+rnd(8), player.y+rnd(8), -0.4, -0.2, rnd(8), rnd(1)+0.5, 9, 0) + end + end end player.particlecooldown = 0.1 end - --shooting + --shooting after cooldown player.shootcooldown -= 1/60 player.inv -= 1/60 if btn(4, player.id) and player.shootcooldown < 0 then @@ -80,11 +88,15 @@ function addplayer(sprite, bulletsprite) --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) - player.shootcooldown = 0.1 + 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) + end + player.shootcooldown = player.shootspeed end end add(players, player) end -addplayer(2, 6)
\ No newline at end of file +addplayer(16, 19)
\ No newline at end of file |
