Skip to content

Commit

Permalink
Init all
Browse files Browse the repository at this point in the history
  • Loading branch information
deltea committed Jun 17, 2021
1 parent 5221bce commit a3a2a36
Show file tree
Hide file tree
Showing 57 changed files with 130 additions and 87 deletions.
Binary file modified assets/imgs/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/activeBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/background0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/background1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/carrot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/carrotPowerup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/cloud0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/cloud1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/cloud2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/coin0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/coin1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/coin2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/coin3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/coinStat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/flagDown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/flagMove0.png
Binary file modified assets/imgs/flagMove1.png
Binary file modified assets/imgs/grassBlock.png
Binary file modified assets/imgs/house.png
Binary file modified assets/imgs/inactiveBox.png
Binary file modified assets/imgs/laser.png
Binary file modified assets/imgs/laserShooter.png
Binary file modified assets/imgs/mushroom.png
Binary file modified assets/imgs/mushroomPowerup.png
Binary file modified assets/imgs/player.png
Binary file modified assets/imgs/playerWalk0.png
Binary file modified assets/imgs/playerWalk1.png
Binary file modified assets/imgs/playerWalk2.png
Binary file modified assets/imgs/snail0.png
Binary file modified assets/imgs/snail1.png
Binary file modified assets/imgs/snailShell.png
Binary file modified assets/imgs/speedBlock.png
Binary file modified assets/imgs/spider0.png
Binary file modified assets/imgs/spider1.png
Binary file modified assets/imgs/spikeBall0.png
Binary file modified assets/imgs/spikeBall1.png
Binary file modified assets/imgs/spring0.png
Binary file modified assets/imgs/spring1.png
Binary file modified assets/imgs/stoneBlock.png
Binary file modified assets/imgs/sword.png
Binary file removed assets/sfx/breakPlatform.mp3
Binary file not shown.
Binary file modified assets/sfx/die.mp3
Binary file not shown.
Binary file removed assets/sfx/powerup.mp3
Binary file not shown.
Binary file added assets/sfx/powerup.wav
Binary file not shown.
Binary file added assets/sfx/powerup2.wav
Binary file not shown.
70 changes: 55 additions & 15 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ function preload() {
// Box
this.load.audio("box", "assets/sfx/box.mp3");

// CarrotPowerup
this.load.audio("powerup", "assets/sfx/powerup.mp3");
// Powerups
this.load.audio("powerup", "assets/sfx/powerup.wav");
this.load.audio("powerup2", "assets/sfx/powerup2.wav");

// Die
this.load.audio("die", "assets/sfx/die.mp3");
Expand Down Expand Up @@ -173,6 +174,7 @@ function create() {
sfx.explosion = this.sound.add("explosion");
sfx.box = this.sound.add("box");
sfx.powerup = this.sound.add("powerup");
sfx.powerup2 = this.sound.add("powerup2");
sfx.die = this.sound.add("die");
sfx.checkpoint = this.sound.add("checkpoint");
sfx.shield = this.sound.add("shield");
Expand Down Expand Up @@ -206,7 +208,6 @@ function create() {

// Player
game.player = this.physics.add.sprite(200, 1100, "player").setScale(0.8);

this.physics.add.collider(game.player, game.house);

// Camera
Expand Down Expand Up @@ -234,6 +235,12 @@ function create() {

// Collider, Player, Block
this.physics.add.collider(game.player, game.blocks, function(player, block) {
if (player.body.touching.right && block.body.touching.left) {
player.x -= 2;
}
if (player.body.touching.left && block.body.touching.right) {
player.x += 2;
}
if (player.body.touching.down && block.body.touching.up && block.texture.key === "speedBlock") {
if (!block.touched) {
block.destroyTimer = 7;
Expand Down Expand Up @@ -310,7 +317,13 @@ function create() {
if (player.body.touching.up && box.body.touching.down) {
if (box.active) {
// SFX
sfx.box.play();
if (box.entity === "carrotPowerup" || box.entity === "mushroomPowerup" || box.entity === "swordPowerup") {
sfx.powerup2.play({
volume: 4
});
} else {
sfx.box.play();
}

// Box
box.setTexture("inactiveBox");
Expand Down Expand Up @@ -459,7 +472,9 @@ function create() {

// Collider Spikes, Player
this.physics.add.overlap(game.player, game.spikes, (player, spike) => {
sfx.die.play();
sfx.die.play({
volume: 2.5
});
this.cameras.main.shake(240, 0.05, false);
player.x = game.checkpoint[0];
player.y = game.checkpoint[1] - 10;
Expand Down Expand Up @@ -544,7 +559,9 @@ function create() {
player.setVelocityY(-500);
} else {
// Die
sfx.die.play();
sfx.die.play({
volume: 2.5
});
this.cameras.main.shake(240, 0.05, false);
player.x = game.checkpoint[0];
player.y = game.checkpoint[1] - 10;
Expand Down Expand Up @@ -594,7 +611,9 @@ function create() {

// Collider Springs, Player
this.physics.add.overlap(game.player, game.springs, (player, spring) => {
sfx.die.play();
sfx.die.play({
volume: 2.5
});
this.cameras.main.shake(240, 0.05, false);
player.x = game.checkpoint[0];
player.y = game.checkpoint[1];
Expand Down Expand Up @@ -695,7 +714,9 @@ function create() {
spider.destroy();
} else {
// Die
sfx.die.play();
sfx.die.play({
volume: 2.5
});
this.cameras.main.shake(240, 0.05, false);
player.x = game.checkpoint[0];
player.y = game.checkpoint[1] - 10;
Expand All @@ -711,7 +732,9 @@ function create() {
// Collider Player, CarrotPowerup
this.physics.add.overlap(game.player, game.carrotPowerup, function(player, powerup) {
// SFX
sfx.powerup.play();
sfx.powerup.play({
volume: 4
});

// Enable
game.carrot = true;
Expand All @@ -729,7 +752,9 @@ function create() {
// Collider Player, SwordPowerup
this.physics.add.overlap(game.player, game.swordPowerup, function(player, powerup) {
// SFX
sfx.powerup.play();
sfx.powerup.play({
volume: 4
});

// Enable
game.sword = true;
Expand All @@ -747,7 +772,9 @@ function create() {
// Collider Player, MushroomPowerup
this.physics.add.overlap(game.player, game.mushroomPowerup, function(player, powerup) {
// SFX
sfx.powerup.play();
sfx.powerup.play({
volume: 4
});

// Enable
game.bounceMagic = true;
Expand Down Expand Up @@ -778,7 +805,9 @@ function create() {
// Collider LaserBlasts, Player
this.physics.add.collider(game.laserBlasts, game.player, (player, blast) => {
// Die
sfx.die.play();
sfx.die.play({
volume: 2.5
});
this.cameras.main.shake(240, 0.05, false);
player.x = game.checkpoint[0];
player.y = game.checkpoint[1] - 10;
Expand Down Expand Up @@ -1048,8 +1077,17 @@ function update() {
game.jumpHeight = 700;
}

// Key function
const keyPress = (key) => {
if (Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(key))) {
return true;
} else {
return false;
}
}

// Shoot
if (Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.C)) && game.carrot) {
if ((keyPress(Phaser.Input.Keyboard.KeyCodes.SPACE) || keyPress(Phaser.Input.Keyboard.KeyCodes.C)) && game.carrot) {
// SFX
sfx.carrot.play();

Expand All @@ -1059,7 +1097,8 @@ function update() {
} else {
game.carrots.create(game.player.x, game.player.y, "carrot").setVelocityY(-400).setVelocityX(-500).setScale(0.5);
}
} else if (Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.X)) && game.sword) {
this.children.bringToTop(game.player);
} else if ((keyPress(Phaser.Input.Keyboard.KeyCodes.DOWN) || keyPress(Phaser.Input.Keyboard.KeyCodes.X)) && game.sword) {
// SFX
sfx.sword.play();

Expand All @@ -1069,6 +1108,7 @@ function update() {
} else {
game.swords.create(game.player.x, game.player.y, "sword").setVelocityY(-400).setVelocityX(-600).setScale(0.7);
}
this.children.bringToTop(game.player);
}

// Respawn
Expand Down Expand Up @@ -1287,7 +1327,7 @@ const config = {
width: 1300,
height: 643,

// Color
// Color of sky
backgroundColor: 0xcfeffc,

// Physics
Expand Down
147 changes: 75 additions & 72 deletions world.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ const world = {
[2060, 122, "grassBlock"],

// Platform
[2600, 762, "speedBlock"],
[2640, 762, "speedBlock"],
[2680, 762, "grassBlock"],
[2720, 762, "grassBlock"],
[2760, 762, "grassBlock"],
Expand All @@ -284,77 +286,78 @@ const world = {
[2960, 762, "grassBlock"],
[3000, 762, "grassBlock"],
[3040, 762, "grassBlock"],
[3180, 762, "grassBlock"],
[3220, 762, "grassBlock"],
[3260, 762, "grassBlock"],
[3300, 762, "grassBlock"],
[3340, 762, "grassBlock"],
[3380, 762, "grassBlock"],
[3420, 762, "grassBlock"],
[3460, 762, "grassBlock"],
[3500, 762, "grassBlock"],
[3540, 762, "grassBlock"],
[3580, 762, "grassBlock"],
[3620, 762, "grassBlock"],
[3660, 762, "grassBlock"],
[3700, 762, "grassBlock"],
[3740, 762, "grassBlock"],
[3780, 762, "grassBlock"],
[3820, 762, "grassBlock"],
[3860, 762, "grassBlock"],
[3900, 762, "grassBlock"],
[3940, 762, "grassBlock"],
[3980, 762, "grassBlock"],
[4020, 762, "grassBlock"],
[4060, 762, "grassBlock"],
[4100, 762, "grassBlock"],
[4140, 762, "grassBlock"],
[4180, 762, "grassBlock"],
[4220, 762, "grassBlock"],
[4260, 762, "grassBlock"],
[4300, 762, "grassBlock"],
[4340, 762, "grassBlock"],
[4380, 762, "grassBlock"],
[4420, 762, "grassBlock"],
[4460, 762, "grassBlock"],
[4500, 762, "grassBlock"],
[4540, 762, "grassBlock"],
[4580, 762, "grassBlock"],
[4620, 762, "grassBlock"],
[4660, 762, "grassBlock"],
[4700, 762, "grassBlock"],
[4740, 762, "grassBlock"],
[4780, 762, "grassBlock"],
[4820, 762, "grassBlock"],
[4860, 762, "grassBlock"],
[4900, 762, "grassBlock"],
[4940, 762, "grassBlock"],
[4980, 762, "grassBlock"],
[5020, 762, "grassBlock"],
[5060, 762, "grassBlock"],
[5100, 762, "grassBlock"],
[5140, 762, "grassBlock"],
[5180, 762, "grassBlock"],
[5220, 762, "grassBlock"],
[5260, 762, "grassBlock"],
[5300, 762, "grassBlock"],
[5340, 762, "grassBlock"],
[5380, 762, "grassBlock"],
[5420, 762, "grassBlock"],
[5460, 762, "grassBlock"],
[5500, 762, "grassBlock"],
[5540, 762, "grassBlock"],
[5580, 762, "grassBlock"],
[5620, 762, "grassBlock"],
[5660, 762, "grassBlock"],
[5700, 762, "grassBlock"],
[5740, 762, "grassBlock"],
[5780, 762, "grassBlock"],
[5820, 762, "grassBlock"],
[5860, 762, "grassBlock"],
[5900, 762, "grassBlock"],
[5940, 762, "grassBlock"],
[5980, 762, "grassBlock"],

[3180, 762, "speedBlock"],
[3220, 762, "speedBlock"],
[3260, 762, "speedBlock"],
[3300, 762, "speedBlock"],
[3340, 762, "speedBlock"],
[3380, 762, "speedBlock"],
[3420, 762, "speedBlock"],
[3460, 762, "speedBlock"],
[3500, 762, "speedBlock"],
[3540, 762, "speedBlock"],
[3580, 762, "speedBlock"],
[3620, 762, "speedBlock"],
[3660, 762, "speedBlock"],
[3700, 762, "speedBlock"],
[3740, 762, "speedBlock"],
[3780, 762, "speedBlock"],
[3820, 762, "speedBlock"],
[3860, 762, "speedBlock"],
[3900, 762, "speedBlock"],
[3940, 762, "speedBlock"],
[3980, 762, "speedBlock"],
[4020, 762, "speedBlock"],
[4060, 762, "speedBlock"],
[4100, 762, "speedBlock"],
[4140, 762, "speedBlock"],
[4180, 762, "speedBlock"],
[4220, 762, "speedBlock"],
[4260, 762, "speedBlock"],
[4300, 762, "speedBlock"],
[4340, 762, "speedBlock"],
[4380, 762, "speedBlock"],
[4420, 762, "speedBlock"],
[4460, 762, "speedBlock"],
[4500, 762, "speedBlock"],
[4540, 762, "speedBlock"],
[4580, 762, "speedBlock"],
[4620, 762, "speedBlock"],
[4660, 762, "speedBlock"],
[4700, 762, "speedBlock"],
[4740, 762, "speedBlock"],
[4780, 762, "speedBlock"],
[4820, 762, "speedBlock"],
[4860, 762, "speedBlock"],
[4900, 762, "speedBlock"],
[4940, 762, "speedBlock"],
[4980, 762, "speedBlock"],
[5020, 762, "speedBlock"],
[5060, 762, "speedBlock"],
[5100, 762, "speedBlock"],
[5140, 762, "speedBlock"],
[5180, 762, "speedBlock"],
[5220, 762, "speedBlock"],
[5260, 762, "speedBlock"],
[5300, 762, "speedBlock"],
[5340, 762, "speedBlock"],
[5380, 762, "speedBlock"],
[5420, 762, "speedBlock"],
[5460, 762, "speedBlock"],
[5500, 762, "speedBlock"],
[5540, 762, "speedBlock"],
[5580, 762, "speedBlock"],
[5620, 762, "speedBlock"],
[5660, 762, "speedBlock"],
[5700, 762, "speedBlock"],
[5740, 762, "speedBlock"],
[5780, 762, "speedBlock"],
[5820, 762, "speedBlock"],
[5860, 762, "speedBlock"],
[5900, 762, "speedBlock"],
[5940, 762, "speedBlock"],
[5980, 762, "speedBlock"],

// Mini wall
[2880, 1122, "grassBlock"],
Expand Down Expand Up @@ -406,7 +409,7 @@ const world = {
[2620, 1110],

// On box
[1640, 421],
[1640, 419],

// Underground
[5926, 1110],
Expand Down

0 comments on commit a3a2a36

Please # to comment.