From 0d372df5dee079e1c99bbbb2d0e9a7de7dc3fd9e Mon Sep 17 00:00:00 2001 From: Rauwomos Date: Sat, 5 Oct 2019 16:57:58 +0100 Subject: [PATCH 1/5] Attempt at turning on/off light with timer, after switch is stepped on --- images/background.png | Bin 0 -> 20355 bytes images/black_layer.png | Bin 0 -> 20312 bytes images/light-mask.png | Bin 0 -> 13608 bytes js/main.js | 2 +- js/sceneMain.js | 75 ++++++++++++++++++++++++++++++++++++----- 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 images/background.png create mode 100644 images/black_layer.png create mode 100644 images/light-mask.png diff --git a/images/background.png b/images/background.png new file mode 100644 index 0000000000000000000000000000000000000000..96e5d4b6e6268219c76da4468fade947d35f19ed GIT binary patch literal 20355 zcmeHPO=uHA6n>j*)9tpws0WLJtXr&Jx|`IBWZ8s`Ms1~OYwe-EC2i9-)clZaNi2d% z5o}LhJctx2co%x`QZLnuAc8#z_0p3CgQzD#(H@-5U$Z%T5x&5Z$=f&Y%^Q;JoA-S) zYhxqV-Qr1+h}=Vi;c+5o*}4Q5lSH0<*k^D2d?*qk+I-k~5Nl(frJ2F;2+?vcQSm;} zZzd|TPD@^*FHs`xG0}<4`qoXI-RQ^+PUVO?k6RZ;jHD1+mnu)nXPpMojEEb?@-BEptS8dp4U3E*U zjb;;Z=Gn3z^yw8%o2=$XS1spFgQ-SZk+M*OqOLZkEhrAZJ~u^V&`>xuQQ*GqZo27= z$NB2>A9a6=U+euCU7*FgYrF5hzV9)L#5s7uBUKwu#e>m%KmE-jb}!S`Wj<)pbU0kg z8~o8m&q||M`tGtz3}f3k@Uk)JqLPeCGRpA4FaQAAfhVA644?z_2GEkJKD20*v4r%0e%fNlZ0 z1?U!_TOdgW-2!wA&@Di>0Nny~3(ze2c+olFol2J*{tS}jAFknl4K;w|4Wi={Q5M{PIg$e&H`vc#sLNa3<4MgFbH4}z#xD@0D}Mq0Sp2d o1TY9-Q2p$&>VabadRsyJ@GbGp+kqE8>!`b-t0Up(m!m6x0inSO+W-In literal 0 HcmV?d00001 diff --git a/images/black_layer.png b/images/black_layer.png new file mode 100644 index 0000000000000000000000000000000000000000..7407ef0198e255896193b2bc659495ee25b63e43 GIT binary patch literal 20312 zcmeHPO=uHA6rSB|+cj-!LN7&Bmd(M7*-fGqyKKTnqivySODQxx2u<2F2F;JzEs36z zLct>F&4ct%u;)T=;wdPe?Lp{8M8rcu#0r9Hj}dl4_{!(=H>1CW+p#7^S$rQ z#>~{1$9>982=Ppe$7cy~9oUE1OD&0~Z$8o|Asb7?2-$tq|2x$~U!N$AFPMb%57`Gt zo@@>i!Y$_t}q!Hz!5|pEENs{#P@`^Sazuvl>zKX~Efytk!2g`=;5@}%B>tD z70gz*Xa`mM9W|r`)uY(-Qr)&{)8$--BHQt!A-(Cz*jhNcYJ+z)#_4I(O1m0$>*~?4 zMctDx&MgpPkcoI~uF8Gh-}N+t1FqPsUtc!24+npK;I}W`Nx#gly!-RrCmA)u@q*}e zP9E^tulebrF6(^5nD04uvc0|D;GS#DTkpJB5Qh&mHlD!qz4zXWaw~ir$91Exjp&#R zqhXvp9TQlP#jQ_le6L6$>i+v(AOqH!t`>8gD^e1CEJ&@s<7&6S0g|M}t-gm6-!THz zA-K2742mEM!oatNFWv>x`+Sh?SG`uNpS`>$vLFp(pN)^fqn|1U58pieZ1JCm8wPF| zxZ7f?!cLJe&m$Zr$yi}vg@NT6*0vx9x(E-jDwHn*s{%?2d>+V9mgEJK3>qFZJaQOF z03myZ)FURz$lD_64aETD7SO6ds{)}9%OgT1MfG2hm_eV%CZD0tgFX++P+own7Mf%T zx*_O>8XlztsKY=J3tOCn3Lq4*pnM9GWEAe9>Je3sC>ce)Etq65$^RRZEUf!S=xz-g z_Fe#;Z3DLlZV%iZxIJ)t;P$}nf!hPOhuwXcLK-B%kpRc0T>pAUvqSFfdGYo7kH^pK Pz3wKiO~rSvEUx_p1dRV> literal 0 HcmV?d00001 diff --git a/images/light-mask.png b/images/light-mask.png new file mode 100644 index 0000000000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^0#?Stxy!zxgOKzEAkrhvV(3!MwpIz z)vo*FTJ`|b0h4U#C!^pY9`g)#bDDXaAu5&bApz1rShVGC4Q1H@K4w>8Xk!}~yyC-9 zU?t?4I5X$1_TH1qPR zmXw-77G(D0L0V{O$)JPrSW`=2pq_Rl@lxBQDG7uNDqPrO7}_)vq5jCu=aBtH`F&e9 z+VE_K(nGqOv!GG2YoAWfs=XwEJ4&ixgPOL8P^~=O`0fgHIV=S-xV`pqQ3*ufXPD!mwm1^|8CtJo2#GBaxP*Zpcmht1$}S&Ar2 zm+$52d*Y(Pe_cjoy=BQE<)n$O_hhelw7m?mEo?s@W@y@YWr(w?F2Xk^f;`_KS3CR$;ECl6#HdJO|azd32~YX zFfjoPJA|yVCX|&I%!*zr!1QEjX^`eFYzo;jE3MQGPzq1M!XM3CC4IVcfVUkK2FQ3Wy_wE+ zyY8+Swq;G9-1;o6KWLE!aS)&G__#Ld7;SOwvVNX70rD( {this.tweens.add({ + targets: this.spotlight, + alpha: 0, + duration: 10000, + ease: 'Sine.easeIn', + })} + }); + this.pressedLightSwitch = true + } + // The above sort of works, but I would rather the spotlight get bigger, than brighter + // if (!this.pressedLightSwitch) { + // this.tweens.add({ + // targets: this.foreground.mask.bitmapMask, + // scale: 1, + // duration: 2000, + // ease: 'Sine.easeIn', + // onComplete: () => {this.tweens.add({ + // targets: this.foreground.mask.bitmapMask, + // scale: 0, + // duration: 10000, + // ease: 'Sine.easeIn', + // })} + // }); + // this.pressedLightSwitch = true + // } + } } From 5bf34b93a5ba56877bf4230e2c9f86b73584468e Mon Sep 17 00:00:00 2001 From: Rauwomos Date: Sun, 6 Oct 2019 09:36:36 +0100 Subject: [PATCH 2/5] Made is so the light can turn on after it turns off --- js/sceneMain.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/sceneMain.js b/js/sceneMain.js index ce04a18..446ff8f 100644 --- a/js/sceneMain.js +++ b/js/sceneMain.js @@ -122,6 +122,7 @@ class SceneMain extends Phaser.Scene { alpha: 0, duration: 10000, ease: 'Sine.easeIn', + onComplete: () => this.pressedLightSwitch = false })} }); this.pressedLightSwitch = true From 0771070cde5f122b95b43a268df75763313487c4 Mon Sep 17 00:00:00 2001 From: Rauwomos Date: Sun, 6 Oct 2019 12:44:18 +0100 Subject: [PATCH 3/5] Added sound effect to light, and made it stay on when you're still on the switch --- js/sceneMain.js | 74 ++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/js/sceneMain.js b/js/sceneMain.js index 446ff8f..d4e3921 100644 --- a/js/sceneMain.js +++ b/js/sceneMain.js @@ -3,12 +3,15 @@ class SceneMain extends Phaser.Scene { super('SceneMain'); } preload() { - + // Images this.load.image('hero', 'images/hero.png'); this.load.image('star', 'images/star.png') this.load.image('background', 'images/background.png') this.load.image('foreground', 'images/black_layer.png') this.load.image('mask', 'images/light-mask.png') + + // Sound effects + this.load.audio('lightSwitch', 'sound_effects/light_switch.mp3') } create() { @@ -43,7 +46,6 @@ class SceneMain extends Phaser.Scene { this.foreground.mask = new Phaser.Display.Masks.BitmapMask(this, this.spotlight) this.foreground.mask.invertAlpha = true this.foreground.mask.bitmapMask.scale = 3 - console.log(this.foreground.mask) // collider between hero and edge of the scene @@ -57,10 +59,12 @@ class SceneMain extends Phaser.Scene { // Lightswitch scale and initial alpha this.lightswitch.setScale(2); - this.setLightToAlpha(this.distanceFromHero(this.lightswitch), 250) + this.setLightToAlpha(this.distanceFromHero(this.lightswitch), 200) - this.physics.add.overlap(this.hero, this.lightswitch, this.turnOnLight, null, this); + this.physics.add.overlap(this.hero, this.lightswitch, () => this.turnOnLight({onDuration: 7000}), null, this); this.pressedLightSwitch = false + + this.lightSwitchSound = this.sound.add('lightSwitch') } update() { @@ -88,9 +92,14 @@ class SceneMain extends Phaser.Scene { // If hero is moving in any direction if (this.hero.body.velocity.x || this.hero.body.velocity.y) { - this.setLightToAlpha(this.distanceFromHero(this.lightswitch), 250) + let distance = this.distanceFromHero(this.lightswitch) + this.setLightToAlpha(distance, 200) this.foreground.mask.bitmapMask.x = this.hero.x this.foreground.mask.bitmapMask.y = this.hero.y + if (this.pressedLightSwitch && distance > 65) { + // this.pressedLightSwitch = false + this.turnOffLight({onDuration: 1000}) + } } } @@ -99,7 +108,7 @@ class SceneMain extends Phaser.Scene { let xCoord = Math.abs(el.body.x - this.hero.body.x) let yCoord = Math.abs(el.body.y - this.hero.body.y) - return xCoord + yCoord + return Math.sqrt(xCoord**2 + yCoord**2) } setLightToAlpha(distance, scale) { @@ -110,38 +119,39 @@ class SceneMain extends Phaser.Scene { this.lightswitch.alpha = alpha } - turnOnLight() { + turnOnLight(options) { + let onDuration = 10000 + if ('onDuration' in options) { + onDuration = options.onDuration + } if (!this.pressedLightSwitch) { + this.lightSwitchSound.play() this.tweens.add({ targets: this.spotlight, alpha: 1, - duration: 2000, - ease: 'Sine.easeIn', - onComplete: () => {this.tweens.add({ - targets: this.spotlight, - alpha: 0, - duration: 10000, - ease: 'Sine.easeIn', - onComplete: () => this.pressedLightSwitch = false - })} + duration: 500, + ease: 'Sine.easeIn' }); this.pressedLightSwitch = true } - // The above sort of works, but I would rather the spotlight get bigger, than brighter - // if (!this.pressedLightSwitch) { - // this.tweens.add({ - // targets: this.foreground.mask.bitmapMask, - // scale: 1, - // duration: 2000, - // ease: 'Sine.easeIn', - // onComplete: () => {this.tweens.add({ - // targets: this.foreground.mask.bitmapMask, - // scale: 0, - // duration: 10000, - // ease: 'Sine.easeIn', - // })} - // }); - // this.pressedLightSwitch = true - // } + } + + turnOffLight(options) { + let onDuration = 10000 + if ('onDuration' in options) { + onDuration = options.onDuration + } + if (!this.pressingLightSwitch) { + this.tweens.add({ + targets: this.spotlight, + alpha: 0, + duration: onDuration, + ease: 'Quart.easeIn', + onComplete: () => { + this.pressedLightSwitch = false + this.lightSwitchSound.play() + } + }) + } } } From 139e9e4de21520bdea19dda30358724bc5831e69 Mon Sep 17 00:00:00 2001 From: Rauwomos Date: Sun, 6 Oct 2019 12:45:09 +0100 Subject: [PATCH 4/5] Added sound effect --- sound_effects/light_switch.mp3 | Bin 0 -> 4968 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sound_effects/light_switch.mp3 diff --git a/sound_effects/light_switch.mp3 b/sound_effects/light_switch.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..914dcb30be821e17932ca108191ceb73e4957a3f GIT binary patch literal 4968 zcmdUzXHb+&vw+`Sf=gZ`2Vq&3oTDHp8A&Th&Pl=&MG#RySVTM$l$;TP1;hm;FHr%> zS%Msrf&>9kkhtXca_ZjW-}~$P@jX>jGc`Rm-80oa)ji-z3I_Opu=MbCzgR+d(I^3c z0Rxc#3(p@6{^0$GfnaF_=gK!w+z(KS~B8_3jQQb|5~_*K#>t&0FZ@$ z>`;Da-ubWKzqJQXP#Azr^(`R32C%~D5#$~K5&}t}1m8SIAWX1aCGh9V7iS~!!InY5 zeci=C$8R5BgGc8u03Z*;a-Z9Qf}2KCw+9(6&0zs@(!@Bp#l;<#wUM`xW1GR#4}M36 zAb7giNjhI!kklp!Kq{#L5(vx)JSoJG0}xh{-e1b9Fgkz@olgy6TW8^I90H)If}*Qe zB>}Cl^Q{s%cpeqGaI$d;1P>7~#ni|jssPaDC_-58 z%k2v_eB$wFZ^?uldLC2PRuW@$?NiA%IJK6AzvKcN?6%bSb;>ysb$EBYoDf;LaF4OP z3kfOj)t*E$Oa`2JO~7ES+Jy8rGRPtQEKk+9rKAUX*&rYrk>`IY^?qHZiyON4G6ya_ zQ;L6~{pIDNd_PsEi3HNlzgNM*@N+d^pHs(IF=Nvedwb1aL1M*W)W*J8xQ`L~fkhmS z-2pt?c(uCZK)WQIFo)lJ&0^BB+(B0A6?AEm7!KlR!K0=~mT1kz?T2&LxQNOr{v%7$P8SA-vh{xQyjZD z3_j4*(i*vSGIA!b=hX+HQFFOBe7m*xZlmvKCXY{c|J*C)zl3gGL)41s1tt_GfkfAW z?2POjQdlZ;?1l738Ol`o>8r1tz6E7ejsbuz zcxbqX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wr+178FXg}g{Z>g5 zm%P(qx!n1rpzvESW1kKGuT_T+j9N_UA+>t{)L*;+$&QWT`ZKLD2mB8j<&Imo-aE;a zq1x4w%LSCT+5H$O`O0*Cw{i^%2Zrw3HlVI6ygMz9*@(9P>`ogmw@_$gdWAFhVaZ8V z@<^SH6|R`fJbNmBr$6dx{S!k9tZn*}13kl%Q7=pCBe1WcO@F-g+(X=XQS=Q(EHYYvu=7%JMx$e3lmaXsFmGpmeMx`II~=ps$eZD-CyPhFY^ z+UHl6Z#b{kY*?n|7=N=>e>NgB@Ig^>1^Ewa#z}YuU`>y8<`tgTh~ZSh4jA#n0h43-*(w1kI_` zJpV3vl;cuWRs10IR56&c##kWej%>Poj8reg*ALIdvclq;cx~UB`1PiQnLgaKkF7h; z4ONTLRlYVVgnHwCs~jm?sOy`}pDpjLoTbGLhA$0*=P@cR2f^UUQw$1AVsBvZ=sRby zz3wAwj2pY2&UABjc13v!Wo8zQ{KG(C-Z;M*zZ?v_0iJXjPl-X{ZsqZpfwRsgg09`7q zatSK@B8(o0I*xK08$|MkoBMB>()Dhu=#qA;D$f!iXpV7H;A5Hqx zEMsa4E%UM+0qJNmlXH~`EQCiARSR?^>AQud$%AKBJ4x2-uBi93GnY%-tN{SH*dId@ z|GN$#7$I3x6jNHrj;0Hp9jh5!KBi)@1Qc?Z9mlQF+GRn2i0=3z;dSs3&a0Kh(y ci!zuFFcnl>q)R{X1^7&}e?P9orSbprKW7Zv(EtDd literal 0 HcmV?d00001 From a8a279102b29349ebb235225678004c40a60f53e Mon Sep 17 00:00:00 2001 From: Rauwomos Date: Sun, 6 Oct 2019 13:06:38 +0100 Subject: [PATCH 5/5] finished merge and fixing behavior --- js/sceneMain.js | 51 +++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/js/sceneMain.js b/js/sceneMain.js index 03849c2..1b0ebf6 100644 --- a/js/sceneMain.js +++ b/js/sceneMain.js @@ -27,29 +27,6 @@ class SceneMain extends Phaser.Scene { this.centerX = this.game.config.width/2; this.centerY = this.game.config.height/2; - // placing hero in the center of the screen - this.hero = this.physics.add.sprite(this.centerX, this.centerY, 'hero'); - - //CREATE ALL ASSETS ABOVE THIS LINE - - // Darkness rectangle - this.foreground = this.add.image(0, 0, 'foreground') - this.foreground.scaleX = this.game.config.width / this.foreground.scaleX - this.foreground.scaleY = this.game.config.height / this.foreground.scaleY - - this.spotlight = this.make.sprite({ - x: 300, - y: 300, - key: 'mask', - add: false - }); - this.spotlight.alpha = 0 - - this.foreground.mask = new Phaser.Display.Masks.BitmapMask(this, this.spotlight) - this.foreground.mask.invertAlpha = true - this.foreground.mask.bitmapMask.scale = 3 - - // placing sprites in the center of the screen this.hero = this.physics.add.sprite(this.centerX, this.centerY, 'hero'); this.door = this.physics.add.sprite(this.centerX, this.centerY, 'door'); @@ -102,6 +79,26 @@ class SceneMain extends Phaser.Scene { count++; }) }) + + //CREATE ALL ASSETS ABOVE THIS LINE + + // Darkness rectangle + this.foreground = this.add.image(0, 0, 'foreground') + this.foreground.scaleX = this.game.config.width / this.foreground.scaleX + this.foreground.scaleY = this.game.config.height / this.foreground.scaleY + + this.spotlight = this.make.sprite({ + x: 300, + y: 300, + key: 'mask', + add: false + }); + this.spotlight.alpha = 0 + + this.foreground.mask = new Phaser.Display.Masks.BitmapMask(this, this.spotlight) + this.foreground.mask.invertAlpha = true + this.foreground.mask.bitmapMask.scale = 3 + // Attention future people - do this for a dynamic group of sprites with collision this.physics.add.collider(this.wallGroup, this.hero) @@ -113,7 +110,7 @@ class SceneMain extends Phaser.Scene { this.setLightToAlpha(this.distanceFromHero(this.lightswitch), 200) - this.physics.add.overlap(this.hero, this.lightswitch, () => this.turnOnLight({onDuration: 7000}), null, this); + this.physics.add.overlap(this.hero, this.lightswitch, () => this.turnOnLight(), null, this); this.pressedLightSwitch = false this.lightSwitchSound = this.sound.add('lightSwitch') @@ -150,7 +147,7 @@ class SceneMain extends Phaser.Scene { this.foreground.mask.bitmapMask.y = this.hero.y if (this.pressedLightSwitch && distance > 65) { // this.pressedLightSwitch = false - this.turnOffLight({onDuration: 1000}) + this.turnOffLight({onDuration: 10000}) } } } @@ -171,7 +168,7 @@ class SceneMain extends Phaser.Scene { this.lightswitch.alpha = alpha } - turnOnLight(options) { + turnOnLight(options = {}) { let onDuration = 10000 if ('onDuration' in options) { onDuration = options.onDuration @@ -188,7 +185,7 @@ class SceneMain extends Phaser.Scene { } } - turnOffLight(options) { + turnOffLight(options = {}) { let onDuration = 10000 if ('onDuration' in options) { onDuration = options.onDuration