Skip to content

Commit 5221bce

Browse files
committed
Init all
1 parent 77bc400 commit 5221bce

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

script.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,12 @@ function create() {
322322
} else if (box.entity === "carrotPowerup") {
323323
// Create carrotPowerup
324324
game.carrotPowerup.create(box.x, box.y - 30, "carrotPowerup").setCollideWorldBounds(true).setScale(0.5).setVelocityY(-500);
325-
} else {
325+
} else if (box.entity === "mushroomPowerup") {
326326
// Create mushroomPowerup
327327
game.mushroomPowerup.create(box.x, box.y - 30, "mushroomPowerup").setCollideWorldBounds(true).setScale(0.8).setVelocityY(-500);
328+
} else {
329+
// Create swordPowerup
330+
game.swordPowerup.create(box.x, box.y - 30, "sword").setCollideWorldBounds(true).setScale(0.8).setVelocityY(-500);
328331
}
329332
}
330333
}
@@ -710,13 +713,31 @@ function create() {
710713
// SFX
711714
sfx.powerup.play();
712715

713-
// Add to coins
716+
// Enable
714717
game.carrot = true;
715718

716719
// Destroy
717720
powerup.destroy();
718721
});
719722

723+
// SwordPowerup
724+
game.swordPowerup = this.physics.add.group();
725+
726+
// Collider Box, SwordPowerup
727+
this.physics.add.collider(game.boxes, game.swordPowerup);
728+
729+
// Collider Player, SwordPowerup
730+
this.physics.add.overlap(game.player, game.swordPowerup, function(player, powerup) {
731+
// SFX
732+
sfx.powerup.play();
733+
734+
// Enable
735+
game.sword = true;
736+
737+
// Destroy
738+
powerup.destroy();
739+
});
740+
720741
// MushroomPowerup
721742
game.mushroomPowerup = this.physics.add.group();
722743

@@ -728,7 +749,7 @@ function create() {
728749
// SFX
729750
sfx.powerup.play();
730751

731-
// Add to coins
752+
// Enable
732753
game.bounceMagic = true;
733754

734755
// Destroy
@@ -1204,7 +1225,7 @@ function update() {
12041225
// Check
12051226
if (sprite.timer < 0) {
12061227
// Reset timer
1207-
sprite.timer = 100;
1228+
sprite.timer = 200;
12081229

12091230
// Attributes
12101231
laserBlast = game.laserBlasts.create(sprite.x, sprite.y, "laser");

world.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ const world = {
407407

408408
// On box
409409
[1640, 421],
410+
411+
// Underground
412+
[5926, 1110],
410413
],
411414
boxes: [
412415
// Alternate
@@ -434,6 +437,7 @@ const world = {
434437

435438
// Underground
436439
[2880, 922, "coin"],
440+
[5771, 922, "swordPowerup"],
437441
],
438442
spiders: [
439443
// Floating platform
@@ -510,6 +514,8 @@ const world = {
510514
[5080, 1110, false],
511515
[5320, 1110, false],
512516
[5440, 1110, false],
517+
518+
[5706, 1110, false],
513519
],
514520
snails: [
515521
[3000, 1122],
@@ -520,7 +526,7 @@ const world = {
520526
[4330, 953, "R"],
521527
[4380, 995, "R"],
522528
[4426, 1040, "R"],
523-
[4526, 4426, "L"],
529+
[5526, 1115, "L"],
524530
],
525531
flags: [
526532
// Box

0 commit comments

Comments
 (0)