@@ -7,13 +7,12 @@ import LaserGroup from '../Js/LaserGroup';
77import SlashGroup from '../Js/SlashGroup' ;
88import LocalStorage from '../Tools/localStorage' ;
99
10-
1110let cursors ;
1211const speedX = 385 ;
1312let gameOver = false ;
1413let blast ;
1514let timer = true ;
16- let timerSlash = true
15+ let timerSlash = true ;
1716
1817const 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 ) ;
0 commit comments