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