Skip to content

Commit

Permalink
Fixed treasure bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikketer committed Jul 13, 2024
1 parent d5c853f commit 193e1c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Island {
const hitYZone = [pirate.sprite.y - 4, pirate.sprite.y + 2]

// Check to see if we slashed the treasure!
if (_treasureSprite) {
if (_treasureSprite && isSegmentComplete) {
openTreasure()
return
}
Expand Down Expand Up @@ -114,6 +114,7 @@ namespace Island {
}

function showTreasure() {
console.log("Showing treasure")
_treasureSprite = sprites.create(treasureImage)
const randX = Math.randomRange(_boundingBox[0] + 20, _boundingBox[2] - 15)
const randY = Math.randomRange(_boundingBox[1] + 50, _boundingBox[3] - 15)
Expand Down Expand Up @@ -161,6 +162,8 @@ namespace Island {
_treasureSprite.destroy()
}

music.stopAllSounds()

// Remove all listeners and clear the screen
controller.player1.B.removeEventListener(ControllerButtonEvent.Pressed, leaveIsland)

Expand All @@ -169,10 +172,15 @@ namespace Island {

export function init(island: Map.Island) {
_island = island
isSegmentComplete = false
currentSegment = 0

scene.setBackgroundColor(8)
player1 = new Pirate({ control: controller.player1, playerNumber: 0, onAttack: onPirateAttack })
player2 = new Pirate({ control: controller.player2, playerNumber: 1, onAttack: onPirateAttack })

music.play(music.createSong(assets.song`Theme`), music.PlaybackMode.LoopingInBackground)

drawBackground()
// Baddies
placeEnemies()
Expand Down
3 changes: 2 additions & 1 deletion map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Map {
segments: number
}

// const weBeSailinSong: Buffer = assets.song`We be Sailin`
let cursor: Sprite
let waves: Array<Sprite> = []
let currentSelectedIslandIndex = 0
Expand Down Expand Up @@ -62,7 +63,7 @@ namespace Map {
export function init(islands: Array<Island>) {
scene.setBackgroundColor(6)

// music.play(music.createSong(assets.song`We Boat`), music.PlaybackMode.LoopingInBackground)
music.play(music.createSong(assets.song`We be Sailin`), music.PlaybackMode.LoopingInBackground)

_islands = islands
// Cursor
Expand Down

0 comments on commit 193e1c1

Please sign in to comment.