summaryrefslogtreecommitdiff
path: root/world.lua
diff options
context:
space:
mode:
Diffstat (limited to 'world.lua')
-rw-r--r--world.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/world.lua b/world.lua
index ff7a1ad..58dae39 100644
--- a/world.lua
+++ b/world.lua
@@ -6,6 +6,7 @@ local Textbox = require("textbox")
local Enemy = require("enemy")
local BloodParticle = require("bloodParticle")
local DustSystem = require("dustParticle")
+local sfx = require("sfx")
local World = {}
World.__index = World
@@ -236,6 +237,7 @@ end
function World:handlePickup(pickup, player)
if pickup and player and pickup.isPickup and self:_isPlayerLike(player) then
+ if not pickup.collected then sfx.play("pickup") end
pickup:pickup(self, player)
end
end
@@ -250,7 +252,7 @@ function World:handleDoor(door, player)
if keyCount >= needed then
self.doorOpened = true
self.playerTextbox:show(
- "The door opens! You escaped!",
+ "Bye Bye!",
{ player.x + player.width / 2, player.y - 20, "center" },
"write",
{ life = 5, fontSize = 9, centeredText = true, wrapToFit = true }
@@ -321,11 +323,15 @@ function World:_onBeginContact(udA, udB, nx, ny, contact)
end
if type(udA) == "table" and udA.type == "water" and self:_isTrackedEntity(udB) then
+ local wasInWater = (self.waterContacts[udB] or 0) > 0
self.waterContacts[udB] = (self.waterContacts[udB] or 0) + 1
doWaterSplash(udA, udB)
+ if not wasInWater and self:_isPlayerLike(udB) then sfx.play("dive") end
elseif type(udB) == "table" and udB.type == "water" and self:_isTrackedEntity(udA) then
+ local wasInWater = (self.waterContacts[udA] or 0) > 0
self.waterContacts[udA] = (self.waterContacts[udA] or 0) + 1
doWaterSplash(udB, udA)
+ if not wasInWater and self:_isPlayerLike(udA) then sfx.play("dive") end
end
local playerEntity, hazardNx, hazardNy