From d1bf4bc62180ffc557b462a48af1e7283b523a3d Mon Sep 17 00:00:00 2001 From: Margaux Boileau <144930772+Margaux-Boileau@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:45:21 +0100 Subject: [PATCH] death by fall --- main.py | 17 +++++++++++++++++ main.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/main.py b/main.py index 134dd54..291b57e 100644 --- a/main.py +++ b/main.py @@ -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: @@ -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 diff --git a/main.ts b/main.ts index 16d12eb..5249429 100644 --- a/main.ts +++ b/main.ts @@ -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) { @@ -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