Skip to content

Commit

Permalink
mario jump progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Margaux-Boileau committed Dec 12, 2023
1 parent b3b1244 commit 913f931
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 18 deletions.
47 changes: 37 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("""
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -563,6 +589,7 @@ def on_on_update():
backgroundmenu: Sprite = None
listCoinIndex = 0
tall = 0
facingRight = 1
marioLevel: Sprite = None
initializeGame()
initializeMenu()
50 changes: 42 additions & 8 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
`)
}

}
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 913f931

Please sign in to comment.