Skip to content

Commit

Permalink
Fixed looting enemies
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikketer committed Jul 15, 2024
1 parent 85fe825 commit 3ab7c77
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
5 changes: 5 additions & 0 deletions images.g.jres
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
"mimeType": "image/x-mkcd-f4",
"displayName": "Pirate"
},
"image17": {
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADw/wAAAODu7u7uAAAADu7u7u4AAAAAoA6gzAAAAACg3a2sAAAAAK7d26oAAACgrt3dqgAAAKCq3d2qAAAAoKre3aoAAAAAqt6trAAAAAAAAADdAAAAAAAAAN0AAAAAAADw/w==",
"mimeType": "image/x-mkcd-f4",
"displayName": "Militia Broken and Broke Left"
},
"anim14": {
"namespace": "myAnimations",
"id": "anim14",
Expand Down
19 changes: 19 additions & 0 deletions images.g.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,25 @@ d d d 7 7 7 7 d d d . . . . . .
d d a a a c c d d . . . . . . .
. a a a . . c c . . . . . . . .
. f f f f . f f f . . . . . . .
`;
case "image17":
case "Militia Broken and Broke Left":return img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . e . . . . . . . . . .
. . . . e . . . . a a a . . . .
. . . . e e . . e e a a a . . .
. . . . e e a a a a a a a . . .
. . . . e e e d d d d e e . . .
. . . . e e . d d d d d d . . .
. . . . e e . d b d d d d . . .
. . . f e e a a d d d d a . . f
. . . f e e c c a a a a c d d f
. . . f e e c a a a a a a d d f
`;
}
return null;
Expand Down
16 changes: 10 additions & 6 deletions island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,26 @@ namespace Island {

// manually check each enemy to see if they overlap, also check for parry
currentEnemies.forEach((enemy) => {
if (enemy.health <= 0 && enemy.riches > 0) {
enemy.lootTheBody()
}

// Don't hurt the dead, that's just mean
if (enemy.health <= 0) return
if (enemy.health <= 0 && enemy.riches <= 0) return
if (direction === 'right'
&& enemy.sprite.x >= hitXZone[0] && enemy.sprite.x <= hitXZone[1]
// Bottom of pirate is overlapping the top of the enemy (and opposite)
&& hitYZone[1] >= enemy.sprite.y - (enemy.sprite.height / 2) && hitYZone[0] <= enemy.sprite.y + (enemy.sprite.height / 2)) {
if (enemy.health <= 0 && enemy.riches > 0) {
enemy.lootTheBody()
} else {
enemy.hit(1)
}
} else if (direction === 'left'
&& enemy.sprite.x <= hitXZone[0] && enemy.sprite.x >= hitXZone[1]
// Same vertical check as the right side
&& hitYZone[1] >= enemy.sprite.y - (enemy.sprite.height / 2) && hitYZone[0] <= enemy.sprite.y + (enemy.sprite.height / 2)) {
enemy.hit(1)
if (enemy.health <= 0 && enemy.riches > 0) {
enemy.lootTheBody()
} else {
enemy.hit(1)
}
}
})

Expand Down
2 changes: 1 addition & 1 deletion map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace Map {
_bulkyBgSprite.z = 2

music.play(music.createSong(assets.song`We be Sailin`), music.PlaybackMode.LoopingInBackground)
TreasureStats.show({ combination: ['island', 'boat'] })
TreasureStats.show({ combination: ['island', 'boat'], location: 'left' })

// Cursor
cursor = sprites.create(assets.image`empty`)
Expand Down
7 changes: 6 additions & 1 deletion militia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ class Militia {
const oldY = this.sprite.y

this.sprite.destroy()
this.sprite = sprites.create(assets.image`Militia Broken and Broke`)
if (this.facing === 'left') {
this.sprite = sprites.create(assets.image`Militia Broken and Broke Left`)
} else {
this.sprite = sprites.create(assets.image`Militia Broken and Broke`)
}

this.sprite.x = oldX
this.sprite.y = oldY
}
Expand Down
2 changes: 1 addition & 1 deletion treasureStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace TreasureStats {
const locX = currentPosition === 'center' ? 80 : 5

const scoreSprite = textsprite.create(text + '', 1, 15)
scoreSprite.x = locX + 8 + (scoreSprite.width / 2)
scoreSprite.x = locX + 10 + (scoreSprite.width / 2)
scoreSprite.y = currentY
scoreSprite.z = 100
treasureSprites.push(scoreSprite)
Expand Down

0 comments on commit 3ab7c77

Please sign in to comment.