Skip to content

Commit

Permalink
finishes water splash
Browse files Browse the repository at this point in the history
  • Loading branch information
mswieboda committed May 1, 2021
1 parent e04eac4 commit 1db303b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Binary file added assets/sounds/splash.mp3
Binary file not shown.
Binary file added assets/sounds/splash.ogg
Binary file not shown.
23 changes: 16 additions & 7 deletions source/escape/Player.hx
Expand Up @@ -259,17 +259,26 @@ class Player extends FlxSprite {

// TODO: see if i really *need* to return a Bool, as I don't currently use it in Level#updateCollisions
public function onWaterTile(tile: FlxObject, feetTrigger: FlxObject): Bool {
inWater = true;
// check a fake/temp hitbox, with an offset, and width/height adjustments
var overlapFound = feetTrigger.x + feetTrigger.width > tile.x
&& feetTrigger.x < tile.x + tile.width
&& feetTrigger.y + feetTrigger.height > tile.y
&& feetTrigger.y < tile.y + tile.height;

if (!alreadyHitWater) {
alreadyHitWater = true;
if (overlapFound) {
inWater = true;

FlxG.camera.shake(0.0015, 0.15);
// TODO: switch to splash sound
playSound("jump", 1);
if (!alreadyHitWater) {
alreadyHitWater = true;

// TODO: add a particle splash at the intersection point

playSound("splash", 0.3);
FlxG.camera.shake(0.0015, 0.15);
}
}

return true;
return overlapFound;
}

function animateWalk() {
Expand Down

0 comments on commit 1db303b

Please sign in to comment.