Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
fauwara committed May 11, 2022
1 parent e0e2ad3 commit 14087db
Show file tree
Hide file tree
Showing 10 changed files with 541 additions and 2,220 deletions.
26 changes: 4 additions & 22 deletions game/js/bootGame.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
class bootGame extends Phaser.Scene {

constructor() {
super("bootGame");
}

preload() {
// html to get user input
// this.load.html('nameform', 'game/assets/user-input.html');
//images
// main menu images
this.load.image("title", "game/assets/title.png");
Expand All @@ -15,7 +14,7 @@ class bootGame extends Phaser.Scene {
// game images
this.load.image("bg", "game/assets/bg.png");
this.load.image("player", "game/assets/samurai.png");
//sprites
// game sprites
this.load.spritesheet("ghost", "game/assets/ghost-sprite.png", {
//ghosts
frameWidth: 75,
Expand All @@ -26,27 +25,11 @@ class bootGame extends Phaser.Scene {
frameWidth: 22,
frameHeight: 22,
});

// audio
// this.load.audio("roblox-death-audio", "src/assets/roblox-death.mp3"); // "src/assets/roblox-death.ogg",
}

create() {

///////////////////////////////////////// create animations
////////////// main menu animations
// play button
this.anims.create({
key: "play",
frames: this.anims.generateFrameNumbers("play", {
start: 0,
end: 1,
}),
frameRate: 5,
repeat: -1,
});

// this.add.text(20, 20, "Loading Game...");
// animations
this.anims.create({
key: "candy_beam",
frames: this.anims.generateFrameNumbers("candy", {
Expand All @@ -56,6 +39,7 @@ class bootGame extends Phaser.Scene {
frameRate: 5,
repeat: -1,
});

// ghost walk animation
this.anims.create({
key: "ghost_walk",
Expand All @@ -67,8 +51,6 @@ class bootGame extends Phaser.Scene {
repeat: -1,
});

// this.deathSound = this.sound.add("roblox-death-audio");

this.scene.start("mainMenu");
}
}
1 change: 1 addition & 0 deletions game/js/console-messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
console.log(" Hows the music? \n\n .\n |\ \n _j .___,\n (_j |---|\n _| |\n .____. (_j _|\n |.--.| . (_J\n |l__j| .\n |+ oo| .\n l____j\n\n");

// * _____
// * __/_ ///
// * / _/ \
Expand Down
3 changes: 2 additions & 1 deletion game/js/endScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class endScene extends Phaser.Scene {
"Content-type": "application/json; charset=UTF-8"
}
})

.then(res => res.json())
.then(json => console.log(json));

Expand All @@ -33,7 +34,7 @@ class endScene extends Phaser.Scene {
playButton.setInteractive();

playButton.on('pointerdown', () => {
this.scene.start("mainGame");
this.scene.start("stage1");
});
}
}
8 changes: 1 addition & 7 deletions game/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var config = {
type: Phaser.AUTO,
width: 1200,
height: 675,
scene: [bootGame, mainMenu, mainGame, endScene],
scene: [bootGame, mainMenu, stage1, stage2, endScene],
pixelArt: true,
dom: {
createContainer: true
Expand All @@ -16,13 +16,7 @@ var config = {
},
};

var player; //player
var playerSpeed = 200;
var distance;
var target = new Phaser.Math.Vector2();
var candyTarget = new Phaser.Math.Vector2();

// actually need these ig
// var userId;

var game = new Phaser.Game(config);
188 changes: 0 additions & 188 deletions game/js/mainGame.js

This file was deleted.

65 changes: 13 additions & 52 deletions game/js/mainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,25 @@ class mainMenu extends Phaser.Scene {
super("mainMenu");
}

preload() {
this.load.html('nameform', 'game/assets/user-input.html');
}
preload() {
this.load.html('nameform', 'game/assets/user-input.html');
}

create() {
// this.add.text(20, 20, "Loading Game...");
// let playButton = this.physics.add.image(config.width/2, config.height/2, "player");

// game title
this.add.image(600, 200, 'title');

// user input
var element = this.add.dom(600, 330).createFromCache('nameform');

let htplay = this.add.image(400, 430, 'htplay').setInteractive();
// game title
this.add.image(600, 200, 'title');

// user input
var element = this.add.dom(600, 330).createFromCache('nameform');

let htplay = this.add.image(400, 430, 'htplay').setInteractive();
let play = this.add.image(600, 430, 'play').setInteractive();
let leaderboard = this.add.image(800, 430, 'trophy').setInteractive();

play.on('pointerdown', () => {
var userId = element.getChildByName('user-id');
this.scene.start("mainGame", {name: userId.value, score: 0});
var userId = element.getChildByName('user-id');
this.scene.start("stage1", { name: userId.value, score: 0 });
});

// element.setPerspective(800);
// element.addListener('click');

// element.on('click', function (event) {

// if (event.target.name === 'playButton')
// {
// var inputText = this.getChildByName('nameField');

// // Have they entered anything?
// if (inputText.value !== '')
// {
// // Turn off the click events
// this.removeListener('click');

// // Hide the login element
// this.setVisible(false);

// // Populate the text with whatever they typed in
// text.setText('Welcome ' + inputText.value);
// }
// else
// {
// // Flash the prompt
// this.scene.tweens.add({
// targets: text,
// alpha: 0.2,
// duration: 250,
// ease: 'Power3',
// yoyo: true
// });
// }
// }

// });

}
}
Loading

0 comments on commit 14087db

Please sign in to comment.