diff --git a/main.py b/main.py index 53246fc..134dd54 100644 --- a/main.py +++ b/main.py @@ -40,22 +40,23 @@ def on_on_destroyed(sprite2): def jumpAnimation(): animation.stop_animation(animation.AnimationTypes.ALL, marioLevel) if tall: - if marioLevel.vx > 0: + if facingRight: marioLevel.set_image(assets.image(""" tall_mario_jump_right """)) - elif marioLevel.vx < 0: + else: marioLevel.set_image(assets.image(""" tall_mario_jump_left """)) - elif marioLevel.vx > 0: - marioLevel.set_image(assets.image(""" - jump_right - """)) - elif marioLevel.vx < 0: - marioLevel.set_image(assets.image(""" - jump_left - """)) + else: + if facingRight: + marioLevel.set_image(assets.image(""" + jump_right + """)) + else: + marioLevel.set_image(assets.image(""" + jump_left + """)) def initializeMenu(): global backgroundmenu, mario, title_onep, title_twop, selector_ig, selector, spriteCoinBrillante, spriteCoinOscura, listCoins, list2 backgroundmenu = sprites.create(assets.image(""" @@ -319,6 +320,8 @@ def on_hit_wall2(sprite5, location): scene.on_hit_wall(SpriteKind.Shroom, on_hit_wall2) def on_right_pressed(): + global facingRight + facingRight = 1 if marioLevel.vy == 0: if tall: animation.run_image_animation(marioLevel, @@ -349,6 +352,8 @@ def deathMario(): spawnEnemies() def on_left_pressed(): + global facingRight + facingRight = 0 if marioLevel.vy == 0: if tall: animation.run_image_animation(marioLevel, @@ -535,6 +540,27 @@ def on_on_update(): myTile1 """)) game.on_update(on_on_update) +def on_on_update2(): + if level != 0: + if marioLevel.vx == 0 and marioLevel.vy == 0: + if tall: + if facingRight: + marioLevel.set_image(assets.image(""" + tall_mario_right0 + """)) + else: + marioLevel.set_image(assets.image(""" + tall_mario_left + """)) + elif facingRight: + marioLevel.set_image(assets.image(""" + mario_right + """)) + else: + marioLevel.set_image(assets.image(""" + mario_left + """)) +game.on_update(on_on_update2) boost: Sprite = None turtle: Sprite = None shroom: Sprite = None @@ -563,6 +589,7 @@ def on_on_update(): backgroundmenu: Sprite = None listCoinIndex = 0 tall = 0 +facingRight = 1 marioLevel: Sprite = None initializeGame() initializeMenu() \ No newline at end of file diff --git a/main.ts b/main.ts index 0b75028..16d12eb 100644 --- a/main.ts +++ b/main.ts @@ -41,24 +41,24 @@ sprites.onDestroyed(SpriteKind.coinTwo, function on_on_destroyed(sprite2: Sprite function jumpAnimation() { animation.stopAnimation(animation.AnimationTypes.All, marioLevel) if (tall) { - if (marioLevel.vx > 0) { + if (facingRight) { marioLevel.setImage(assets.image` tall_mario_jump_right `) - } else if (marioLevel.vx < 0) { + } else { marioLevel.setImage(assets.image` tall_mario_jump_left `) } - } else if (marioLevel.vx > 0) { + } else if (facingRight) { marioLevel.setImage(assets.image` - jump_right - `) - } else if (marioLevel.vx < 0) { + jump_right + `) + } else { marioLevel.setImage(assets.image` - jump_left - `) + jump_left + `) } } @@ -339,6 +339,8 @@ scene.onHitWall(SpriteKind.Shroom, function on_hit_wall2(sprite5: Sprite, locati }) controller.right.onEvent(ControllerButtonEvent.Pressed, function on_right_pressed() { + + facingRight = 1 if (marioLevel.vy == 0) { if (tall) { animation.runImageAnimation(marioLevel, assets.animation` @@ -367,6 +369,8 @@ function deathMario() { } controller.left.onEvent(ControllerButtonEvent.Pressed, function on_left_pressed() { + + facingRight = 0 if (marioLevel.vy == 0) { if (tall) { animation.runImageAnimation(marioLevel, assets.animation` @@ -571,6 +575,35 @@ game.onUpdate(function on_on_update() { } } +}) +game.onUpdate(function on_on_update2() { + if (level != 0) { + if (marioLevel.vx == 0 && marioLevel.vy == 0) { + if (tall) { + if (facingRight) { + marioLevel.setImage(assets.image` + tall_mario_right0 + `) + } else { + marioLevel.setImage(assets.image` + tall_mario_left + `) + } + + } else if (facingRight) { + marioLevel.setImage(assets.image` + mario_right + `) + } else { + marioLevel.setImage(assets.image` + mario_left + `) + } + + } + + } + }) let boost : Sprite = null let turtle : Sprite = null @@ -600,6 +633,7 @@ let mario : Sprite = null let backgroundmenu : Sprite = null let listCoinIndex = 0 let tall = 0 +let facingRight = 1 let marioLevel : Sprite = null initializeGame() initializeMenu()