Skip to content

Commit

Permalink
death mario
Browse files Browse the repository at this point in the history
  • Loading branch information
polmarrod committed Dec 12, 2023
1 parent f31d793 commit 2e0d294
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 117 deletions.
Binary file modified .github/makecode/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions main.blocks

Large diffs are not rendered by default.

151 changes: 88 additions & 63 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@ class SpriteKind:
Prize = SpriteKind.create()

def on_right_released():
animation.stop_animation(animation.AnimationTypes.ALL, marioLevel)
if tall:
marioLevel.set_image(assets.image("""tall_mario_right0"""))
else:
marioLevel.set_image(assets.image("""
mario_right
"""))
if level != 0 :
animation.stop_animation(animation.AnimationTypes.ALL, marioLevel)
if tall:
marioLevel.set_image(assets.image("""tall_mario_right0"""))
else:
marioLevel.set_image(assets.image("""
mario_right
"""))
controller.right.on_event(ControllerButtonEvent.RELEASED, on_right_released)

def on_left_released():
animation.stop_animation(animation.AnimationTypes.ALL, marioLevel)
if tall:
marioLevel.set_image(assets.image("""
tall_mario_left
"""))
else:
marioLevel.set_image(assets.image("""
mario_left
"""))
if level != 0 :
animation.stop_animation(animation.AnimationTypes.ALL, marioLevel)
if tall:
marioLevel.set_image(assets.image("""
tall_mario_left
"""))
else:
marioLevel.set_image(assets.image("""
mario_left
"""))
controller.left.on_event(ControllerButtonEvent.RELEASED, on_left_released)

def on_on_destroyed(sprite2):
Expand Down Expand Up @@ -124,6 +126,17 @@ def on_down_pressed():
if marioLevel.tilemap_location().column == 58 or marioLevel.tilemap_location().column == 59 and marioLevel.tilemap_location().row == 9 or marioLevel.tilemap_location().row == 10 :
tiles.set_current_tilemap(tilemap("""nivel"""))
tiles.place_on_tile(marioLevel, tiles.get_tile_location(2, 0))
for value in tiles.get_tiles_by_type(assets.tile("""
coin_block
""")):
coin = sprites.create(assets.image("""
coin_sprite
"""), SpriteKind.Coin)
tiles.place_on_tile(coin, value)
tiles.set_tile_at(value, assets.tile("""
transparency16
"""))

controller.down.on_event(ControllerButtonEvent.PRESSED, on_down_pressed)

def buildCabecera():
Expand Down Expand Up @@ -339,59 +352,68 @@ def on_hit_wall2(sprite5, location):

def on_right_pressed():
global facingRight
facingRight = 1
if marioLevel.vy == 0:
if tall:
animation.run_image_animation(marioLevel,
assets.animation("""
tall_mario_walk_right
"""),
150,
True)
else:
animation.run_image_animation(marioLevel,
assets.animation("""
mario_walk_right
"""),
150,
True)
if marioLevel.tile_kind_at(TileDirection.RIGHT, assets.tile("""tube_right_top0 """)):
tiles.set_current_tilemap(tilemap("""level_1_0"""))
tiles.place_on_tile(marioLevel, tiles.get_tile_location(166, 11))
if level != 0:
facingRight = 1
if marioLevel.vy == 0:
if tall:
animation.run_image_animation(marioLevel,
assets.animation("""
tall_mario_walk_right
"""),
150,
True)
else:
animation.run_image_animation(marioLevel,
assets.animation("""
mario_walk_right
"""),
150,
True)
if marioLevel.tile_kind_at(TileDirection.RIGHT, assets.tile("""tube_right_top0 """)):
tiles.set_current_tilemap(tilemap("""level_1_0"""))
tiles.place_on_tile(marioLevel, tiles.get_tile_location(166, 11))

controller.right.on_event(ControllerButtonEvent.PRESSED, on_right_pressed)

def deathMario():
info.stop_countdown()
info.change_life_by(-1)
info.set_score(0)
info.change_countdown_by(400 - info.countdown())
tiles.set_current_tilemap(tilemap("""level_1_0"""))
sprites.destroy_all_sprites_of_kind(SpriteKind.Shroom)
sprites.destroy_all_sprites_of_kind(SpriteKind.Turtle)
sprites.destroy_all_sprites_of_kind(SpriteKind.Shell)
tall = 0
tiles.place_on_tile(marioLevel, tiles.get_tile_location(0, 13))
spawnEnemies()
global tall
if tall == 1 :
tall = 0
if facingRight:
marioLevel.set_image(assets.image("""mario_right"""))
else:
marioLevel.set_image(assets.image("""mario_left"""))
else:
info.stop_countdown()
info.change_life_by(-1)
info.set_score(0)
info.change_countdown_by(400 - info.countdown())
tiles.set_current_tilemap(tilemap("""level_1_0"""))
tiles.place_on_tile(marioLevel, tiles.get_tile_location(0, 12))
sprites.destroy_all_sprites_of_kind(SpriteKind.Shroom)
sprites.destroy_all_sprites_of_kind(SpriteKind.Turtle)
sprites.destroy_all_sprites_of_kind(SpriteKind.Shell)
spawnEnemies()

def on_left_pressed():
global facingRight
facingRight = 0
if marioLevel.vy == 0:
if tall:
animation.run_image_animation(marioLevel,
assets.animation("""
tall_mario_walk_left
"""),
150,
True)
else:
animation.run_image_animation(marioLevel,
assets.animation("""
mario_walk_left
"""),
150,
True)
if level == 1 :
facingRight = 0
if marioLevel.vy == 0:
if tall:
animation.run_image_animation(marioLevel,
assets.animation("""
tall_mario_walk_left
"""),
150,
True)
else:
animation.run_image_animation(marioLevel,
assets.animation("""
mario_walk_left
"""),
150,
True)
controller.left.on_event(ControllerButtonEvent.PRESSED, on_left_pressed)

def changePostionSelector(selection: number):
Expand Down Expand Up @@ -615,7 +637,10 @@ def on_hit_wall3(sprite, location):
""")):
sprites.destroy(sprite)
scene.on_hit_wall(SpriteKind.Coin, on_hit_wall3)

def on_overlap(sprite, otherSprite):
sprites.destroy(otherSprite)
info.change_score_by(10)
sprites.on_overlap(SpriteKind.player, SpriteKind.Coin, on_overlap)
boost: Sprite = None
turtle: Sprite = None
shroom: Sprite = None
Expand Down
141 changes: 90 additions & 51 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,32 @@ namespace SpriteKind {
}

controller.right.onEvent(ControllerButtonEvent.Released, function on_right_released() {
animation.stopAnimation(animation.AnimationTypes.All, marioLevel)
if (tall) {
marioLevel.setImage(assets.image`tall_mario_right0`)
} else {
marioLevel.setImage(assets.image`
mario_right
`)
if (level != 0) {
animation.stopAnimation(animation.AnimationTypes.All, marioLevel)
if (tall) {
marioLevel.setImage(assets.image`tall_mario_right0`)
} else {
marioLevel.setImage(assets.image`
mario_right
`)
}

}

})
controller.left.onEvent(ControllerButtonEvent.Released, function on_left_released() {
animation.stopAnimation(animation.AnimationTypes.All, marioLevel)
if (tall) {
marioLevel.setImage(assets.image`
tall_mario_left
`)
} else {
marioLevel.setImage(assets.image`
mario_left
`)
if (level != 0) {
animation.stopAnimation(animation.AnimationTypes.All, marioLevel)
if (tall) {
marioLevel.setImage(assets.image`
tall_mario_left
`)
} else {
marioLevel.setImage(assets.image`
mario_left
`)
}

}

})
Expand Down Expand Up @@ -120,6 +126,7 @@ sprites.onOverlap(SpriteKind.Player, SpriteKind.Shroom, function on_on_overlap(s

})
controller.down.onEvent(ControllerButtonEvent.Pressed, function on_down_pressed() {
let coin: Sprite;

if (level == 0) {
if (selector == 0) {
Expand All @@ -130,6 +137,17 @@ controller.down.onEvent(ControllerButtonEvent.Pressed, function on_down_pressed(
} else if (marioLevel.tilemapLocation().column == 58 || marioLevel.tilemapLocation().column == 59 && marioLevel.tilemapLocation().row == 9 || marioLevel.tilemapLocation().row == 10) {
tiles.setCurrentTilemap(tilemap`nivel`)
tiles.placeOnTile(marioLevel, tiles.getTileLocation(2, 0))
for (let value of tiles.getTilesByType(assets.tile`
coin_block
`)) {
coin = sprites.create(assets.image`
coin_sprite
`, SpriteKind.Coin)
tiles.placeOnTile(coin, value)
tiles.setTileAt(value, assets.tile`
transparency16
`)
}
}

})
Expand Down Expand Up @@ -358,52 +376,69 @@ 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`
tall_mario_walk_right
`, 150, true)
} else {
animation.runImageAnimation(marioLevel, assets.animation`
mario_walk_right
`, 150, true)
if (level != 0) {
facingRight = 1
if (marioLevel.vy == 0) {
if (tall) {
animation.runImageAnimation(marioLevel, assets.animation`
tall_mario_walk_right
`, 150, true)
} else {
animation.runImageAnimation(marioLevel, assets.animation`
mario_walk_right
`, 150, true)
}

}

if (marioLevel.tileKindAt(TileDirection.Right, assets.tile`tube_right_top0 `)) {
tiles.setCurrentTilemap(tilemap`level_1_0`)
tiles.placeOnTile(marioLevel, tiles.getTileLocation(166, 11))
}

}

if (marioLevel.tileKindAt(TileDirection.Right, assets.tile`tube_right_top0 `)) {
})
function deathMario() {

if (tall == 1) {
tall = 0
if (facingRight) {
marioLevel.setImage(assets.image`mario_right`)
} else {
marioLevel.setImage(assets.image`mario_left`)
}

} else {
info.stopCountdown()
info.changeLifeBy(-1)
info.setScore(0)
info.changeCountdownBy(400 - info.countdown())
tiles.setCurrentTilemap(tilemap`level_1_0`)
tiles.placeOnTile(marioLevel, tiles.getTileLocation(166, 11))
tiles.placeOnTile(marioLevel, tiles.getTileLocation(0, 12))
sprites.destroyAllSpritesOfKind(SpriteKind.Shroom)
sprites.destroyAllSpritesOfKind(SpriteKind.Turtle)
sprites.destroyAllSpritesOfKind(SpriteKind.Shell)
spawnEnemies()
}

})
function deathMario() {
info.stopCountdown()
info.changeLifeBy(-1)
info.setScore(0)
info.changeCountdownBy(400 - info.countdown())
tiles.setCurrentTilemap(tilemap`level_1_0`)
sprites.destroyAllSpritesOfKind(SpriteKind.Shroom)
sprites.destroyAllSpritesOfKind(SpriteKind.Turtle)
sprites.destroyAllSpritesOfKind(SpriteKind.Shell)
let tall = 0
tiles.placeOnTile(marioLevel, tiles.getTileLocation(0, 13))
spawnEnemies()
}

controller.left.onEvent(ControllerButtonEvent.Pressed, function on_left_pressed() {

facingRight = 0
if (marioLevel.vy == 0) {
if (tall) {
animation.runImageAnimation(marioLevel, assets.animation`
tall_mario_walk_left
`, 150, true)
} else {
animation.runImageAnimation(marioLevel, assets.animation`
mario_walk_left
`, 150, true)
if (level == 1) {
facingRight = 0
if (marioLevel.vy == 0) {
if (tall) {
animation.runImageAnimation(marioLevel, assets.animation`
tall_mario_walk_left
`, 150, true)
} else {
animation.runImageAnimation(marioLevel, assets.animation`
mario_walk_left
`, 150, true)
}

}

}
Expand Down Expand Up @@ -677,6 +712,10 @@ scene.onHitWall(SpriteKind.Coin, function on_hit_wall3(sprite: Sprite, location:
}

})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Coin, function on_overlap(sprite: Sprite, otherSprite: Sprite) {
sprites.destroy(otherSprite)
info.changeScoreBy(10)
})
let boost : Sprite = null
let turtle : Sprite = null
let shroom : Sprite = null
Expand Down
Loading

0 comments on commit 2e0d294

Please sign in to comment.