diff --git a/script.js b/script.js index e8201b2..b61e772 100644 --- a/script.js +++ b/script.js @@ -322,9 +322,12 @@ function create() { } else if (box.entity === "carrotPowerup") { // Create carrotPowerup game.carrotPowerup.create(box.x, box.y - 30, "carrotPowerup").setCollideWorldBounds(true).setScale(0.5).setVelocityY(-500); - } else { + } else if (box.entity === "mushroomPowerup") { // Create mushroomPowerup game.mushroomPowerup.create(box.x, box.y - 30, "mushroomPowerup").setCollideWorldBounds(true).setScale(0.8).setVelocityY(-500); + } else { + // Create swordPowerup + game.swordPowerup.create(box.x, box.y - 30, "sword").setCollideWorldBounds(true).setScale(0.8).setVelocityY(-500); } } } @@ -710,13 +713,31 @@ function create() { // SFX sfx.powerup.play(); - // Add to coins + // Enable game.carrot = true; // Destroy powerup.destroy(); }); + // SwordPowerup + game.swordPowerup = this.physics.add.group(); + + // Collider Box, SwordPowerup + this.physics.add.collider(game.boxes, game.swordPowerup); + + // Collider Player, SwordPowerup + this.physics.add.overlap(game.player, game.swordPowerup, function(player, powerup) { + // SFX + sfx.powerup.play(); + + // Enable + game.sword = true; + + // Destroy + powerup.destroy(); + }); + // MushroomPowerup game.mushroomPowerup = this.physics.add.group(); @@ -728,7 +749,7 @@ function create() { // SFX sfx.powerup.play(); - // Add to coins + // Enable game.bounceMagic = true; // Destroy @@ -1204,7 +1225,7 @@ function update() { // Check if (sprite.timer < 0) { // Reset timer - sprite.timer = 100; + sprite.timer = 200; // Attributes laserBlast = game.laserBlasts.create(sprite.x, sprite.y, "laser"); diff --git a/world.js b/world.js index c7c3327..941bf09 100644 --- a/world.js +++ b/world.js @@ -407,6 +407,9 @@ const world = { // On box [1640, 421], + + // Underground + [5926, 1110], ], boxes: [ // Alternate @@ -434,6 +437,7 @@ const world = { // Underground [2880, 922, "coin"], + [5771, 922, "swordPowerup"], ], spiders: [ // Floating platform @@ -510,6 +514,8 @@ const world = { [5080, 1110, false], [5320, 1110, false], [5440, 1110, false], + + [5706, 1110, false], ], snails: [ [3000, 1122], @@ -520,7 +526,7 @@ const world = { [4330, 953, "R"], [4380, 995, "R"], [4426, 1040, "R"], - [4526, 4426, "L"], + [5526, 1115, "L"], ], flags: [ // Box