Skip to content

Commit

Permalink
coins and anims
Browse files Browse the repository at this point in the history
  • Loading branch information
Margaux-Boileau committed Dec 12, 2023
1 parent f05c278 commit 728e39a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
31 changes: 21 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ def startGame():
info.set_life(3)
info.set_score(0)
info.start_countdown(400)
for value in tiles.get_tiles_by_type(assets.tile("""
prize_block
""")):
prize = sprites.create(assets.image("""
prize_block_0
"""), SpriteKind.Prize)
tiles.place_on_tile(prize, value)
animation.run_image_animation(prize,
assets.animation("""
prize_block_anim
"""),
200,
True)

def on_hit_wall2(sprite5, location):
if sprite5.is_hitting_tile(CollisionDirection.RIGHT):
Expand Down Expand Up @@ -519,20 +532,18 @@ def on_on_update():
global boost
if level != 0:
spawnEnemies()
for value22 in tiles.get_tiles_by_type(assets.tile("""
prize_block
""")):

if marioLevel.tilemap_location().column == value22.column and marioLevel.tilemap_location().row == value22.row + 1:
for value in sprites.all_of_kind(SpriteKind.Prize):
if marioLevel.tilemap_location().column == value.tilemap_location().column and marioLevel.tilemap_location().row == value.tilemap_location().row + 1:
coin = sprites.create(assets.image("""
coin_sprite
"""), SpriteKind.Coin)
tiles.place_on_tile(coin, value22)
coin_sprite
"""), SpriteKind.Coin)
tiles.place_on_tile(coin, value.tilemap_location())
coin.vy = -200
coin.ay = 400
info.change_score_by(10)

tiles.set_tile_at(value22, assets.tile("""
animation.stop_animation(animation.AnimationTypes.ALL, value)
sprites.destroy(value)
tiles.set_tile_at(value.tilemap_location(), assets.tile("""
myTile1
"""))
for value222 in tiles.get_tiles_by_type(assets.tile("""
Expand Down
28 changes: 20 additions & 8 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ function on_hit_wall(sprite6: Sprite, location2: tiles.Location) {

scene.onHitWall(SpriteKind.Food, on_hit_wall)
function startGame() {
let prize: Sprite;

scene.setBackgroundImage(img`
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Expand Down Expand Up @@ -330,6 +331,17 @@ function startGame() {
info.setLife(3)
info.setScore(0)
info.startCountdown(400)
for (let value of tiles.getTilesByType(assets.tile`
prize_block
`)) {
prize = sprites.create(assets.image`
prize_block_0
`, SpriteKind.Prize)
tiles.placeOnTile(prize, value)
animation.runImageAnimation(prize, assets.animation`
prize_block_anim
`, 200, true)
}
}

scene.onHitWall(SpriteKind.Shroom, function on_hit_wall2(sprite5: Sprite, location: tiles.Location) {
Expand Down Expand Up @@ -549,18 +561,18 @@ game.onUpdate(function on_on_update() {

if (level != 0) {
spawnEnemies()
for (let value22 of tiles.getTilesByType(assets.tile`
prize_block
`)) {
if (marioLevel.tilemapLocation().column == value22.column && marioLevel.tilemapLocation().row == value22.row + 1) {
for (let value of sprites.allOfKind(SpriteKind.Prize)) {
if (marioLevel.tilemapLocation().column == value.tilemapLocation().column && marioLevel.tilemapLocation().row == value.tilemapLocation().row + 1) {
coin = sprites.create(assets.image`
coin_sprite
`, SpriteKind.Coin)
tiles.placeOnTile(coin, value22)
coin_sprite
`, SpriteKind.Coin)
tiles.placeOnTile(coin, value.tilemapLocation())
coin.vy = -200
coin.ay = 400
info.changeScoreBy(10)
tiles.setTileAt(value22, assets.tile`
animation.stopAnimation(animation.AnimationTypes.All, value)
sprites.destroy(value)
tiles.setTileAt(value.tilemapLocation(), assets.tile`
myTile1
`)
}
Expand Down

0 comments on commit 728e39a

Please sign in to comment.