Skip to content

Commit 2c82834

Browse files
Matthew WilberMatthew Wilber
Matthew Wilber
authored and
Matthew Wilber
committed
fix merge conflict
2 parents 18728af + 32e99dc commit 2c82834

22 files changed

+177
-11
lines changed

assets/audio/bot_kill.mp3

3.25 KB
Binary file not shown.

assets/audio/end_game.wav

256 KB
Binary file not shown.

assets/audio/intro_jingle.mp3

66.4 KB
Binary file not shown.

assets/audio/intro_loop.mp3

12.4 KB
Binary file not shown.

assets/audio/intro_select.mp3

13.9 KB
Binary file not shown.

assets/audio/intro_start.mp3

21.9 KB
Binary file not shown.

assets/audio/intro_start.wav

59.3 KB
Binary file not shown.

assets/audio/intro_title.wav

107 KB
Binary file not shown.

assets/audio/intro_woosh_hit.mp3

44 KB
Binary file not shown.

assets/audio/jump.wav

26.9 KB
Binary file not shown.

assets/audio/power_down.wav

252 KB
Binary file not shown.

assets/audio/power_up.wav

59.7 KB
Binary file not shown.

assets/audio/start_game.wav

128 KB
Binary file not shown.

assets/audio/success.mp3

6.78 KB
Binary file not shown.

assets/audio/walk.wav

20 KB
Binary file not shown.

assets/images/intro_splash_alpha.png

34.4 KB
Loading

assets/images/intro_splash_beta.png

31.9 KB
Loading

assets/images/intro_splash_bkg.png

165 KB
Loading

assets/images/intro_splash_title.png

13.4 KB
Loading

src/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ const gameConfig = {
4545
]
4646
};
4747

48+
// Set up character selection in local storage
49+
localStorage.setItem("character", "alpha");
50+
4851
new Phaser.Game(gameConfig);

src/scenes/GameScene.js

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ export class GameScene extends Phaser.Scene {
2121
this.load.image('ground', 'assets/images/ground.png');
2222
this.load.image('wall', 'assets/images/wall.png');
2323
this.load.image('platform', 'assets/images/platform.png');
24-
this.load.spritesheet('zeta',
25-
'assets/images/zeta_spritesheet_'+this.character.name+'.png',
26-
{ frameWidth: 40, frameHeight: this.character.height }
24+
this.load.spritesheet('zeta_alpha',
25+
'assets/images/zeta_spritesheet_alpha.png',
26+
{ frameWidth: 40, frameHeight: 66 }
27+
);
28+
this.load.spritesheet('zeta_beta',
29+
'assets/images/zeta_spritesheet_beta.png',
30+
{ frameWidth: 40, frameHeight: 60 }
2731
);
2832
this.load.spritesheet('door',
2933
'assets/images/door.png',
@@ -37,10 +41,20 @@ export class GameScene extends Phaser.Scene {
3741
'assets/images/protector_spritesheet.png',
3842
{ frameWidth: 50, frameHeight: 50 }
3943
);
44+
45+
this.load.audio('aud_end_game', 'assets/audio/end_game.wav');
46+
this.load.audio('aud_jump', 'assets/audio/jump.wav');
47+
this.load.audio('aud_walk', 'assets/audio/walk.wav');
48+
this.load.audio('aud_power_down', 'assets/audio/power_down.wav');
49+
this.load.audio('aud_power_up', 'assets/audio/power_up.wav');
50+
this.load.audio('aud_success', 'assets/audio/success.mp3');
51+
this.load.audio('aud_bot_kill', 'assets/audio/bot_kill.mp3');
4052
}
4153

4254
create() {
4355

56+
this.charactername = 'zeta_'+localStorage.getItem("character");
57+
4458
this.botKillCount = 0;
4559

4660
// Add the background image
@@ -49,6 +63,9 @@ export class GameScene extends Phaser.Scene {
4963
// Set up sprite animations
5064
this.initAnimation();
5165

66+
// Set up the sound fx
67+
this.createAudio();
68+
5269
// Add a game controller with devault arrow keys
5370
this.cursors = this.input.keyboard.createCursorKeys();
5471

@@ -87,29 +104,44 @@ export class GameScene extends Phaser.Scene {
87104
update(scenetime) {
88105

89106
if (this.cursors.left.isDown){
107+
if(!this.audWalk.isPlaying && this.player.body.touching.down) this.audWalk.play();
90108
this.player.setVelocityX(-200);
91109
this.player.anims.play('left', true);
92110
}else if (this.cursors.right.isDown){
111+
if(!this.audWalk.isPlaying && this.player.body.touching.down) this.audWalk.play();
93112
this.player.setVelocityX(200);
94113
this.player.anims.play('right', true);
95114
}else{
115+
this.audWalk.stop();
96116
this.player.setVelocityX(0);
97117
this.player.anims.play('turn');
98118
}
99119

100120
if (this.cursors.up.isDown && this.player.body.touching.down){
121+
this.audJump.play();
101122
this.player.setVelocityY(-750);
102123
}
103124

104125
if( this.botKillCount >= this.botSpawnCount ){
105126
// All bots destroyed
127+
this.audSuccess.play();
106128
this.botKillCount = 0;
107129
this.door.setActive(true);
108130
this.door.anims.play('doorOpen');
109131
}
110132

111133
}
112134

135+
createAudio(){
136+
this.audEndGame = this.sound.add('aud_end_game');
137+
this.audJump = this.sound.add('aud_jump');
138+
this.audWalk = this.sound.add('aud_walk');
139+
this.audPowerDown = this.sound.add('aud_power_down');
140+
this.audPowerUp = this.sound.add('aud_power_up');
141+
this.audSuccess = this.sound.add('aud_success');
142+
this.audBotKill = this.sound.add('aud_bot_kill');
143+
}
144+
113145
createSwitches(){
114146
let switches = this.physics.add.staticGroup();
115147

@@ -148,7 +180,7 @@ export class GameScene extends Phaser.Scene {
148180
}
149181

150182
createPlayer() {
151-
let player = this.physics.add.sprite(400, 450, 'zeta');
183+
let player = this.physics.add.sprite(400, 450, this.charactername);
152184

153185
player.setBounce(0.2);
154186
player.setCollideWorldBounds(true);
@@ -179,8 +211,10 @@ export class GameScene extends Phaser.Scene {
179211

180212
handleCollisionEnemy(player, bot) {
181213
if(bot.active){
214+
this.audEndGame.play();
182215
this.scene.start('EndScene');
183216
}else{
217+
this.audBotKill.play();
184218
let tmpbot = this.physics.add.staticSprite(bot.x, bot.y, 'bot');
185219
tmpbot.anims.play('botAsplode');
186220
bot.destroy();
@@ -220,6 +254,7 @@ export class GameScene extends Phaser.Scene {
220254
}
221255

222256
disableBots(){
257+
this.audPowerDown.play();
223258
for( let bot of this.bots.getChildren() ){
224259
bot.setVelocity(0,0).setActive(false);
225260
}
@@ -231,6 +266,7 @@ export class GameScene extends Phaser.Scene {
231266
}
232267

233268
enableBots(){
269+
this.audPowerUp.play();
234270
for( let botSwitch of this.switches.getChildren() ){
235271
botSwitch.anims.play('switchOn');
236272
botSwitch.setActive(true);
@@ -242,22 +278,28 @@ export class GameScene extends Phaser.Scene {
242278
}
243279

244280
initAnimation() {
281+
282+
// Clear out the zeta anims to allow for character change
283+
this.anims.remove('left');
284+
this.anims.remove('turn');
285+
this.anims.remove('right');
286+
245287
this.anims.create({
246288
key: 'left',
247-
frames: this.anims.generateFrameNumbers('zeta', { start: 0, end: 3 }),
289+
frames: this.anims.generateFrameNumbers(this.charactername, { start: 0, end: 3 }),
248290
frameRate: 20,
249291
repeat: -1
250292
});
251293

252294
this.anims.create({
253295
key: 'turn',
254-
frames: [ { key: 'zeta', frame: 4 } ],
296+
frames: [ { key: this.charactername, frame: 4 } ],
255297
frameRate: 20
256298
});
257299

258300
this.anims.create({
259301
key: 'right',
260-
frames: this.anims.generateFrameNumbers('zeta', { start: 5, end: 8 }),
302+
frames: this.anims.generateFrameNumbers(this.charactername, { start: 5, end: 8 }),
261303
frameRate: 20,
262304
repeat: -1
263305
});

src/scenes/IntroScene.js

Lines changed: 125 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,137 @@ export class IntroScene extends Phaser.Scene {
99
}
1010

1111
preload() {
12-
this.load.image('splash', 'assets/images/intro_splash.png');
12+
this.load.image('intro_bkg', 'assets/images/intro_splash_bkg.png');
13+
this.load.image('intro_title', 'assets/images/intro_splash_title.png');
14+
this.load.spritesheet('intro_alpha',
15+
'assets/images/intro_splash_alpha.png',
16+
{ frameWidth: 208, frameHeight: 483 }
17+
);
18+
this.load.spritesheet('intro_beta',
19+
'assets/images/intro_splash_beta.png',
20+
{ frameWidth: 207, frameHeight: 436 }
21+
);
22+
23+
this.load.audio('aud_intro_jingle', 'assets/audio/intro_jingle.mp3');
24+
this.load.audio('aud_intro_start', 'assets/audio/intro_start.mp3');
25+
this.load.audio('aud_intro_title', 'assets/audio/intro_title.wav');
26+
this.load.audio('aud_intro_wooshhit', 'assets/audio/intro_woosh_hit.mp3');
27+
this.load.audio('aud_select', 'assets/audio/intro_select.mp3');
28+
//this.load.audio('aud_intro_loop','assets/audio/intro_loop.mp3')
1329
}
1430

1531
create() {
32+
33+
this.anims.create({
34+
key: 'alpha_static',
35+
frames: [ { key: 'intro_alpha', frame: 0 } ],
36+
frameRate: 20
37+
});
38+
this.anims.create({
39+
key: 'alpha_hilite',
40+
frames: [ { key: 'intro_alpha', frame: 1 } ],
41+
frameRate: 20
42+
});
43+
this.anims.create({
44+
key: 'beta_static',
45+
frames: [ { key: 'intro_beta', frame: 0 } ],
46+
frameRate: 20
47+
});
48+
this.anims.create({
49+
key: 'beta_hilite',
50+
frames: [ { key: 'intro_beta', frame: 1 } ],
51+
frameRate: 20
52+
});
53+
54+
this.audJingle = this.sound.add('aud_intro_jingle');
55+
this.audStartGame = this.sound.add('aud_intro_start');
56+
this.audSelect = this.sound.add('aud_select');
57+
this.audTitle = this.sound.add('aud_intro_title');
58+
this.audWooshHit = this.sound.add('aud_intro_wooshhit');
59+
//this.audLoop = this.sound.add('aud_intro_loop');
60+
1661
// Add the background image
17-
this.splash = this.add.image(400, 300, 'splash');
62+
this.bkg = this.add.image(400, 300, 'intro_bkg').setAlpha(0);
63+
this.title = this.add.image(400, -300, 'intro_title');
64+
this.alpha = this.add.sprite(1200, 358, 'intro_alpha');
65+
this.beta = this.add.sprite(-204, 382, 'intro_beta');
66+
this.selector = this.add.container();
67+
68+
this.selector.add(this.alpha);
69+
this.selector.add(this.beta);
70+
71+
var timeline = this.tweens.createTimeline();
72+
var timelineb = this.tweens.createTimeline();
73+
timeline.add({
74+
targets: this.bkg,
75+
alpha: 1,
76+
ease: 'QuadraticOut',
77+
duration: 1000,
78+
delay: 0,
79+
onStart: ()=>{this.audJingle.play()}
80+
});
81+
timeline.add({
82+
targets: [this.alpha],
83+
x: 488,
84+
ease: 'QuadraticIn',
85+
duration: 250,
86+
delay: 0,
87+
onStart: ()=>{this.audWooshHit.play()}
88+
});
89+
timelineb.add({
90+
targets: this.beta,
91+
x: 324,
92+
ease: 'QuadraticIn',
93+
duration: 250,
94+
delay: 1000
95+
});
96+
timeline.add({
97+
targets: this.title,
98+
y: 300,
99+
ease: 'Bounce.easeOut',
100+
duration: 1000,
101+
delay: 0,
102+
onStart: ()=>{/*this.audLoop.play('',{loop:true})*/}
103+
});
104+
105+
timeline.play();
106+
timelineb.play();
18107

19-
this.splash.setInteractive().on('pointerdown', () => {
20-
console.log('start game');
108+
this.alpha.setInteractive();
109+
this.beta.setInteractive();
110+
111+
this.alpha.on('pointerdown', () => {
112+
this.audStartGame.play();
113+
localStorage.setItem("character", "alpha");
114+
this.scene.start('Level1');
115+
});
116+
117+
this.beta.on('pointerdown', () => {
118+
this.audStartGame.play();
119+
localStorage.setItem("character", "beta");
21120
this.scene.start('Level1');
121+
22122
});
123+
124+
this.alpha.on('pointerover', () => {
125+
this.audSelect.play();
126+
this.selector.bringToTop(this.alpha);
127+
this.alpha.anims.play('alpha_hilite');
128+
}, this);
129+
130+
this.alpha.on('pointerout', () => {
131+
this.alpha.anims.play('alpha_static');
132+
}, this);
133+
134+
this.beta.on('pointerover', () => {
135+
this.audSelect.play();
136+
this.selector.bringToTop(this.beta);
137+
this.beta.anims.play('beta_hilite');
138+
}, this);
139+
140+
this.beta.on('pointerout', () => {
141+
this.beta.anims.play('beta_static');
142+
}, this);
143+
23144
}
24145
}

0 commit comments

Comments
 (0)