Skip to content

Commit

Permalink
death by fall
Browse files Browse the repository at this point in the history
  • Loading branch information
Margaux-Boileau committed Dec 12, 2023
1 parent 913f931 commit d1bf4bc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def on_on_update():
game.on_update(on_on_update)
def on_on_update2():
if level != 0:
checkFall()
if marioLevel.vx == 0 and marioLevel.vy == 0:
if tall:
if facingRight:
Expand All @@ -561,6 +562,22 @@ def on_on_update2():
mario_left
"""))
game.on_update(on_on_update2)
def checkFall():
if marioLevel.tilemap_location().row == 15:
deathMario()
for value in sprites.all_of_kind(SpriteKind.Shroom):
if value.tilemap_location().row == 15:
sprites.destroy(value)
for value2 in sprites.all_of_kind(SpriteKind.Turtle):
if value2.tilemap_location().row == 15:
sprites.destroy(value2)
for value3 in sprites.all_of_kind(SpriteKind.Food):
if value3.tilemap_location().row == 15:
sprites.destroy(value3)
for value4 in sprites.all_of_kind(SpriteKind.Shell):
if value4.tilemap_location().row == 15:
sprites.destroy(value4)

boost: Sprite = None
turtle: Sprite = None
shroom: Sprite = None
Expand Down
32 changes: 32 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ game.onUpdate(function on_on_update() {
})
game.onUpdate(function on_on_update2() {
if (level != 0) {
checkFall()
if (marioLevel.vx == 0 && marioLevel.vy == 0) {
if (tall) {
if (facingRight) {
Expand Down Expand Up @@ -605,6 +606,37 @@ game.onUpdate(function on_on_update2() {
}

})
function checkFall() {
if (marioLevel.tilemapLocation().row == 15) {
deathMario()
}

for (let value of sprites.allOfKind(SpriteKind.Shroom)) {
if (value.tilemapLocation().row == 15) {
sprites.destroy(value)
}

}
for (let value2 of sprites.allOfKind(SpriteKind.Turtle)) {
if (value2.tilemapLocation().row == 15) {
sprites.destroy(value2)
}

}
for (let value3 of sprites.allOfKind(SpriteKind.Food)) {
if (value3.tilemapLocation().row == 15) {
sprites.destroy(value3)
}

}
for (let value4 of sprites.allOfKind(SpriteKind.Shell)) {
if (value4.tilemapLocation().row == 15) {
sprites.destroy(value4)
}

}
}

let boost : Sprite = null
let turtle : Sprite = null
let shroom : Sprite = null
Expand Down

0 comments on commit d1bf4bc

Please sign in to comment.