From 7ebd91e70b9132d32555b974efd62fdeffba8033 Mon Sep 17 00:00:00 2001 From: Hong Luu Date: Sat, 1 Dec 2018 05:25:47 -0800 Subject: [PATCH] Issue #98 Implemented particles, but need to emit from staff and not from face --- client/assets/img/bubble.png | Bin 0 -> 8772 bytes .../img/{fogLayer.png => darknessLayer.png} | Bin client/config/config.js | 12 +++++-- client/index.html | 1 + client/js/gameLoop.js | 11 +++--- client/js/gameLoopTools/particlesUtilities.js | 34 ++++++++++++++++++ client/js/load.js | 1 + 7 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 client/assets/img/bubble.png rename client/assets/img/{fogLayer.png => darknessLayer.png} (100%) create mode 100644 client/js/gameLoopTools/particlesUtilities.js diff --git a/client/assets/img/bubble.png b/client/assets/img/bubble.png new file mode 100644 index 0000000000000000000000000000000000000000..f2caa4c96854f5080eae2be4cde5f9b56f4f319b GIT binary patch literal 8772 zcmV-KBD>v*P)~1biQY0l>5+zHrJeD0>&d4_4%p|{NfC!HNB|wrN^CJO*AV>fwNDyG)nQ;Ic8Bb=h z$MKA}P#W2gB3agIN{T4a5=D_zb5)bY^~>KX6Cm|P0r3tj!lnOtM$P5UDvO;u5DXt5O%_~^(*UdUp#l|)SD;Y zO0(qT#fz7(y1r{^%eIEm(3+oLuzJ0&H5d%!bB4pA)oeE9vwFRrRjbvlFdWDlH9j}b zGu-p{w9m0V#2Y^>4EvS^pVn%v+QP!VL*wnKo3>1D-`T9S=X@t)WZyqF&g)x^nsa>DOL8e(a^wr{8$;#TQ?A8kg@~y?WJh-4Aui zABF>zm1e1hFo@UZ=l9;ReQwu1TgJEUt^2hxPuY1E4Z}2w!nD_2Px2xgIF9GmTjQZ} zw?_W>WTVn-H~qP0YhtR_YC7#5ZL58E(^~rbRqG4gs~grE$Ddz*>~DVb$fJ)v_U)IC zzx)$^s_z4RzXrYkTdRM+DL`W#+qJ@IU`4}$wRi8~&+b_~_^FBd#8%+7H|VTiNsBCX zYSo%oZ#3go_OM$TwlB0mUV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AGa5aBX#c{oJ_=7fzg6 zKKt`GPoH|e*V(uxWf_Kv@rp;F603>4{~!+d5Wk9DNTb2;AMi^TgRr}C`fTT!(`QdU z(`t>+ZJFA#V`6N4daT`UHyX7@RXYKy9om=7kMn_(75%)|>kU?}UR_;2ckZpT%V$n* utY14jx;l;K7|WcjEk2YlPV@FZ1sDKPO6DZEEN$rk0000 + diff --git a/client/js/gameLoop.js b/client/js/gameLoop.js index 8784b63..220b304 100644 --- a/client/js/gameLoop.js +++ b/client/js/gameLoop.js @@ -6,10 +6,11 @@ gameLoop = { init: (data) => { data = typeof data === "undefined" ? {} : data; - gameLoop.player = data.player || config.default.player; - gameLoop.score = data.score || config.default.score; - gameLoop.width = data.width || config.init.screenWidth; - gameLoop.height = data.height || config.init.screenHeight; + gameLoop.player = data.player || config.default.player; + gameLoop.score = data.score || config.default.score; + gameLoop.particles = data.particles || config.default.particles; + gameLoop.width = data.width || config.init.screenWidth; + gameLoop.height = data.height || config.init.screenHeight; gameLoop.xStartRegion = data.xStartRegion || config.gameLoop.xStartRegion; gameLoop.yStartRegion = data.yStartRegion || config.gameLoop.yStartRegion; gameLoop.difficulty = data.difficulty || config.default.settings.difficulty; @@ -39,6 +40,7 @@ gameLoop = { gameLoop.player.sprite = game.add.sprite(...playerStartData); playerUtilities.create(gameLoop.player); darknessUtilities.create(gameLoop.player); + particlesUtilities.create(gameLoop.particles, gameLoop.player); // clicking the mouse during this state will change the control type to mouse game.input.onDown.add(() => { gameLoop.player.controlType = config.default.controls.mouse; }); @@ -55,6 +57,7 @@ gameLoop = { update: () => { mapController.update(); playerUtilities.update(gameLoop.player); + particlesUtilities.update(gameLoop.particles, gameLoop.player); // update score scoreUtilities.setText(gameLoop.score, gameLoop.score.amount + gameLoop.score.bonus); diff --git a/client/js/gameLoopTools/particlesUtilities.js b/client/js/gameLoopTools/particlesUtilities.js new file mode 100644 index 0000000..18d69e5 --- /dev/null +++ b/client/js/gameLoopTools/particlesUtilities.js @@ -0,0 +1,34 @@ +const particlesUtilities = {}; +particlesUtilities.create = (particles, player) => { + let emitterX = player.sprite.x + config.default.particles.offsetX; + let emitterY = player.sprite.y + config.default.particles.offsetY; + particles.emitter = game.add.emitter(emitterX, emitterY, 200); + + particles.emitter.makeParticles(config.default.particles.key); + + particles.emitter.setRotation(0, 100); + particles.emitter.setAlpha(1, 1); + particles.emitter.setScale(0.3, 0, 0.3, 0, 3000); + particles.emitter.gravity = 200; + + // false means don't explode all the sprites at once, but instead release at a rate of one particle per 100ms + // The 5000 value is the lifespan of each particle before it's killed + particles.emitter.start(false, 1000, 100); +}; + +particlesUtilities.update = (particles, player) => { + var px = player.sprite.body.velocity.x; + var py = player.sprite.body.velocity.y; + + px *= -1; + py *= -1; + + particles.emitter.minParticleSpeed.set(px, py); + particles.emitter.maxParticleSpeed.set(px, py); + + particles.emitter.emitX = player.sprite.x + config.default.particles.offsetX; + particles.emitter.emitY = player.sprite.y + config.default.particles.offsetY; + + // emitter.forEachExists(game.world.wrap, game.world); + game.world.wrap(player.sprite, 64); +}; \ No newline at end of file diff --git a/client/js/load.js b/client/js/load.js index 906edff..72a9111 100644 --- a/client/js/load.js +++ b/client/js/load.js @@ -142,6 +142,7 @@ loadState = { game.load.image(config.default.blocks.quarter.key, config.default.blocks.quarter.src); game.load.image(config.default.neutralMap.key, config.default.neutralMap.src); game.load.image(config.default.darkness.key, config.default.darkness.src); + game.load.image(config.default.particles.key, config.default.particles.src); // Game over loads game.load.image(config.gameOverState.restartButton.key, config.gameOverState.restartButton.src);