Skip to content

Commit 58b231d

Browse files
committed
run eslint fix
1 parent 64d40c6 commit 58b231d

9 files changed

Lines changed: 82 additions & 112 deletions

File tree

src/Js/ChaserDude.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,31 @@ class ChaserDude extends Entity {
1919
this.damage = 50;
2020
}
2121

22+
huntPlayer() {
23+
if (this.x < this.scene.player.x) {
24+
// this.play('dudeleft')
25+
this.body.setVelocityX(160);
2226

27+
this.setFlipX(true);
28+
} else {
29+
// this.play('dudeleft')
30+
this.body.setVelocityX(-160);
2331

24-
huntPlayer() {
25-
26-
if(this.x < this.scene.player.x){
27-
// this.play('dudeleft')
28-
this.body.setVelocityX(160);
29-
30-
this.setFlipX(true);
31-
}else{
32-
// this.play('dudeleft')
33-
this.body.setVelocityX(-160);
34-
35-
this.setFlipX(false);
36-
37-
}
32+
this.setFlipX(false);
33+
}
3834
// const headsOrTails = (Math.random() > 0.7);
3935
// this.jump(headsOrTails);
4036
}
4137

4238
update() {
43-
// this.play('dudeleft')
39+
// this.play('dudeleft')
4440

4541
if (Phaser.Math.Distance.Between(this.x, this.y, this.scene.player.x, this.scene.player.y) < 580) {
46-
47-
this.huntPlayer();
48-
49-
}else{
50-
this.play('dudeleft')
51-
// this.body.setVelocityX(0)
52-
// this.play('turn')
42+
this.huntPlayer();
43+
} else {
44+
this.play('dudeleft');
45+
// this.body.setVelocityX(0)
46+
// this.play('turn')
5347
}
5448
}
5549

src/Js/JumperDude.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class JumperDude extends Entity {
3636
const headsOrTails = (Math.random() > 0.7);
3737
this.jump(headsOrTails);
3838
}
39-
//this.x < this.scene.cameras.main.scrollX + this.scene.sys.game.canvas.width - 50
39+
40+
// this.x < this.scene.cameras.main.scrollX + this.scene.sys.game.canvas.width - 50
4041
update() {
4142
if (Phaser.Math.Distance.Between(this.x, this.y, this.scene.player.x, this.scene.player.y) < 580) {
4243
if (this.body.blocked.down) {

src/Js/Laser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Laser extends Phaser.Physics.Arcade.Sprite {
1212
}
1313

1414
fire(x, y) {
15-
this.body.reset(x, y-30);
15+
this.body.reset(x, y - 30);
1616

1717
this.body.setSize(170, 77);
1818

src/Js/LaserGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class LaserGroup extends Phaser.Physics.Arcade.Group {
2020
if (laser) {
2121
laser.fire(x, y);
2222
laser.setScale(0.6);
23-
23+
2424
laser.anims.play('blast');
2525
}
2626
}

src/Js/Slash.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,5 @@ export default class Slash extends Phaser.Physics.Arcade.Sprite {
1818
this.body.enable = true;
1919
this.setActive(true);
2020
this.setVisible(false);
21-
22-
2321
}
2422
}

src/Js/SlashGroup.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ import Phaser from 'phaser';
22
import Slash from './Slash';
33

44
export default class SlashGroup extends Phaser.Physics.Arcade.Group {
5-
constructor(scene) {
6-
super(scene.physics.world, scene);
7-
8-
this.createMultiple({
9-
classType: Slash,
10-
frameQuantity: 1,
11-
active: false,
12-
visible: false,
13-
loop: true,
14-
key: 'groupS',
15-
});
16-
}
17-
18-
bladeSlash(x, y) {
19-
const slash = this.getFirstDead(false);
20-
if (slash) {
21-
slash.blade(x, y-50);
22-
slash.setScale(1);
23-
slash.setSize(195, 157);
24-
slash.anims.play('slash');
25-
}
5+
constructor(scene) {
6+
super(scene.physics.world, scene);
7+
8+
this.createMultiple({
9+
classType: Slash,
10+
frameQuantity: 1,
11+
active: false,
12+
visible: false,
13+
loop: true,
14+
key: 'groupS',
15+
});
16+
}
17+
18+
bladeSlash(x, y) {
19+
const slash = this.getFirstDead(false);
20+
if (slash) {
21+
slash.blade(x, y - 50);
22+
slash.setScale(1);
23+
slash.setSize(195, 157);
24+
slash.anims.play('slash');
2625
}
26+
}
2727
}

src/Scenes/GameScene.js

Lines changed: 38 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import LaserGroup from '../Js/LaserGroup';
77
import SlashGroup from '../Js/SlashGroup';
88
import LocalStorage from '../Tools/localStorage';
99

10-
1110
let cursors;
1211
const speedX = 385;
1312
let gameOver = false;
1413
let blast;
1514
let timer = true;
16-
let timerSlash = true
15+
let timerSlash = true;
1716

1817
const backgroundCreatorForest1 = (scene, count, texture, scrollFactor) => {
1918
let x = 0;
@@ -32,20 +31,16 @@ export default class GameScene extends Phaser.Scene {
3231
this.laserGroup;
3332
this.monsters;
3433
this.monster;
35-
this.chaser
34+
this.chaser;
3635
this.heathText;
3736
this.scoreText;
3837
this.score;
3938
this.model;
4039
this.platformNumber;
4140
this.particles;
4241
this.emitter;
43-
44-
4542
}
4643

47-
48-
4944
create() {
5045
this.model = this.sys.game.globals.model;
5146
if (this.model.musicOn === true && this.model.bgMusicPlaying === false) {
@@ -56,22 +51,22 @@ export default class GameScene extends Phaser.Scene {
5651
}
5752
this.platformNumber = 60;
5853
this.score = 0;
59-
54+
6055
let groundX = 0;
61-
this.createParticles=()=>{
62-
this.particles= this.add.particles('redlight');
63-
this.emitter=this.particles.createEmitter({
64-
56+
this.createParticles = () => {
57+
this.particles = this.add.particles('redlight');
58+
this.emitter = this.particles.createEmitter({
59+
6560
x: 100,
6661
y: 150,
6762
speed: 200,
6863
lifespan: 500,
6964
blendMode: 'ADD',
70-
scale: { start:1, end:0 },
71-
on : false
65+
scale: { start: 1, end: 0 },
66+
on: false,
7267
});
73-
}
74-
68+
};
69+
7570
const groundY = 589;
7671
const platforms = this.physics.add.staticGroup();
7772

@@ -95,49 +90,44 @@ export default class GameScene extends Phaser.Scene {
9590
this.scoreText = this.add.text(26, 16, 'Score: 0', { fontSize: '32px', fill: '#fff' }).setScrollFactor(0);
9691
this.healthText = this.add.text(26, 56, 'Health: 1000', { fontSize: '32px', fill: '#fff' }).setScrollFactor(0);
9792
this.monsters = [];
98-
this.createParticles()
93+
this.createParticles();
9994
const monsterCreator = (num, hord) => {
10095
let corx = 3900;
10196
for (let j = 1; j < hord; j += 1) {
10297
for (let i = 0; i < num; i += 1) {
103-
if(j%7===0||j%5===0){
104-
if(i%2===0){
105-
this.monster = new ChaserDude({
98+
if (j % 7 === 0 || j % 5 === 0) {
99+
if (i % 2 === 0) {
100+
this.monster = new ChaserDude({
106101
scene: this,
107102
x: corx + i * 15,
108103
y: 16,
109104
key: `chaser${i}${j}`,
110-
});
111-
this.physics.add.collider(this.monster, platforms);
112-
this.monsters.push(this.monster);
113-
this.monster.setBounce(2400, 0, 4900, height);
114-
}else{
105+
});
106+
this.physics.add.collider(this.monster, platforms);
107+
this.monsters.push(this.monster);
108+
this.monster.setBounce(2400, 0, 4900, height);
109+
} else {
115110
this.monster = new JumperDude({
116111
scene: this,
117112
x: corx + i * 15,
118113
y: 16,
119114
key: `dude${i}${j}`,
120-
});
121-
this.physics.add.collider(this.monster, platforms);
122-
this.monsters.push(this.monster);
123-
this.monster.setBounce(2400, 0, 4900, height);
124-
125-
115+
});
116+
this.physics.add.collider(this.monster, platforms);
117+
this.monsters.push(this.monster);
118+
this.monster.setBounce(2400, 0, 4900, height);
126119
}
127-
128-
}else{
120+
} else {
129121
this.monster = new JumperDude({
130-
scene: this,
131-
x: corx + i * 15,
132-
y: 16,
133-
key: `dude${i}${j}`,
122+
scene: this,
123+
x: corx + i * 15,
124+
y: 16,
125+
key: `dude${i}${j}`,
134126
});
135127
this.physics.add.collider(this.monster, platforms);
136128
this.monsters.push(this.monster);
137129
this.monster.setBounce(2400, 0, 4900, height);
138-
139130
}
140-
141131
}
142132

143133
corx += 4240;
@@ -152,8 +142,7 @@ export default class GameScene extends Phaser.Scene {
152142
y: 100,
153143
key: 'player',
154144
});
155-
156-
145+
157146
this.cameras.main.setBounds(0, 0, 300000, height);
158147

159148
this.laserGroup = new LaserGroup(this);
@@ -202,11 +191,10 @@ export default class GameScene extends Phaser.Scene {
202191
},
203192
});
204193
});
205-
206194
},
207195
});
208196
};
209-
197+
210198
this.physics.add.collider(platforms, this.player);
211199

212200
this.physics.add.overlap(this.monsters, this.player, null, (mon2, player) => {
@@ -226,7 +214,7 @@ export default class GameScene extends Phaser.Scene {
226214
mon.damg(50);
227215
this.score += 50;
228216
this.scoreText.setText(`Score: ${this.score}`);
229-
this.particles.emitParticleAt(laser.x,laser.y,50);
217+
this.particles.emitParticleAt(laser.x, laser.y, 50);
230218
laser.setVisible(false);
231219
laser.setActive(false);
232220
laser.body.enable = false;
@@ -236,7 +224,7 @@ export default class GameScene extends Phaser.Scene {
236224
mon.damg(250);
237225
this.score += 250;
238226
this.scoreText.setText(`Score: ${this.score}`);
239-
227+
240228
slash.setActive(false);
241229
slash.body.enable = false;
242230
}, null, this);
@@ -249,10 +237,9 @@ export default class GameScene extends Phaser.Scene {
249237
this.keyW = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.W);
250238
this.keyE = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E);
251239

252-
253240
this.anims.create({
254241
key: 'groupS',
255-
frames: [{key: 'groupS', frame: 0 }],
242+
frames: [{ key: 'groupS', frame: 0 }],
256243
frameRate: 2,
257244
repeat: -1,
258245
});
@@ -262,7 +249,7 @@ export default class GameScene extends Phaser.Scene {
262249
frameRate: 7,
263250
repeat: -1,
264251
});
265-
252+
266253
this.anims.create({
267254
key: 'attackD',
268255
frames: this.anims.generateFrameNumbers('attackD', { start: 1, end: 6 }),
@@ -310,8 +297,6 @@ export default class GameScene extends Phaser.Scene {
310297
frameRate: 10,
311298
repeat: -1,
312299
});
313-
314-
315300
}
316301

317302
update() {
@@ -357,27 +342,22 @@ export default class GameScene extends Phaser.Scene {
357342
} else if (cursors.down.isDown && onGround) {
358343
this.player.anims.play('down', true);
359344
} else if (this.keyW.isDown && this.player.flipX === true) {
360-
if(timerSlash){
361-
362-
this.slashGroup.bladeSlash(this.player.x-70, this.player.y);
345+
if (timerSlash) {
346+
this.slashGroup.bladeSlash(this.player.x - 70, this.player.y);
363347
this.player.flipX = true;
364348
this.player.setVelocityX(0);
365349
this.player.anims.play('slash', true);
366350

367351
this.slashInterval();
368352
}
369-
370353
} else if (this.keyW.isDown && this.player.flipX === !true) {
371-
if(timerSlash){
354+
if (timerSlash) {
372355
this.slashGroup.bladeSlash(this.player.x, this.player.y);
373356
this.player.setVelocityX(0);
374357
this.player.anims.play('slash', true);
375358

376359
this.slashInterval();
377360
}
378-
379-
380-
381361
} else if (this.keyE.isDown && this.player.flipX === true) {
382362
if (timer) {
383363
this.laserGroup.fireLaser(this.player.x, this.player.y);

src/Scenes/MenuScene.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export default class MenuScene extends Phaser.Scene {
77
constructor() {
88
super('Menu');
99
}
10-
preload(){
10+
11+
preload() {
1112
this.load.audio('bgMusic', BgTrack);
1213
}
1314

0 commit comments

Comments
 (0)