From d7a286ebb02dc53fc0d7a09e1849830c11ab5c74 Mon Sep 17 00:00:00 2001 From: labelled Date: Fri, 15 Apr 2016 10:15:41 +0100 Subject: [PATCH 1/7] One enemy added This is an enemy I created for the game using the PyxelEdit. --- media/images/blueenemy.png | Bin 0 -> 141 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 media/images/blueenemy.png diff --git a/media/images/blueenemy.png b/media/images/blueenemy.png new file mode 100644 index 0000000000000000000000000000000000000000..4d26c1b14a930bb28942eeda3c92bd1c88d80c2b GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^2|(F!Z*Le10wq`sbrOHF zCNb*Nu=*M`H{R~!04iZ%XmI_xs{ULM6UTv1FOoPE8W@<6hzFvL3`}5UP$EWpdwi_? T-1mPDfdo8V{an^LB{Ts51coBe literal 0 HcmV?d00001 From cd71869a25eb4074d81b95e9387b498697dcfc07 Mon Sep 17 00:00:00 2001 From: labelled Date: Fri, 15 Apr 2016 10:16:51 +0100 Subject: [PATCH 2/7] Beam of the new enemy This is the beam I created in the PyxelEdit. --- media/images/blueenemybeam.png | Bin 0 -> 125 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 media/images/blueenemybeam.png diff --git a/media/images/blueenemybeam.png b/media/images/blueenemybeam.png new file mode 100644 index 0000000000000000000000000000000000000000..47802f43f2f6dc7a44554c828d78de32754b4f21 GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^2|(F!Z!d4;Wl-Q?aS%%k zSYB+hMkOcVVeF@c|M>-hYM|hMg!OAT>3+5u;_@&dFujHOhL6y~t8M9_Ag-sYpUXO@ GgeCw0j2=J$ literal 0 HcmV?d00001 From 2b4a6955ebf83595ac26c2fd30239b5daa8007f3 Mon Sep 17 00:00:00 2001 From: labelled Date: Fri, 15 Apr 2016 10:28:55 +0100 Subject: [PATCH 3/7] Enemy and bullet sprites These are the codes that I have used to create the new enemy and bullet for the game. --- src/sprites/ranger.js | 24 ++++++++++++++++++++++++ src/sprites/rangerBullet.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/sprites/ranger.js create mode 100644 src/sprites/rangerBullet.js diff --git a/src/sprites/ranger.js b/src/sprites/ranger.js new file mode 100644 index 0000000..f54da09 --- /dev/null +++ b/src/sprites/ranger.js @@ -0,0 +1,24 @@ +import Enemy from './enemy'; +import OrbitPlayer from '../behaviors/orbitPlayer'; +import ShootPlayer from '../behaviors/shootPlayer'; + +export default class Ranger extends Enemy { +constructor(game, x, y) { +super(game, x, y, 'blueenemy', 0); + +this.addBehavior(new OrbitPlayer()); +this.addBehavor(new ShootPlayer()); + +this.anchor.set(0.5); +this.body.width = 20; +this.body.height = 30; +this.body.bounce.set(0.6); + +this.health = 40; +this.score = 600; + + + + +} +} \ No newline at end of file diff --git a/src/sprites/rangerBullet.js b/src/sprites/rangerBullet.js new file mode 100644 index 0000000..6750b63 --- /dev/null +++ b/src/sprites/rangerBullet.js @@ -0,0 +1,32 @@ +const BULLET_LIFETIME_MS = 2000; +const BULLET_MAIN_VELOCITY = 500; + +export default class RangerBullet extends Phaser.Sprite { +constructor(game, x, y){ +super(game, x, y, 'blueenemybeam', 0); +game.physics.arcade.enable(this); + +this.anchor.setTo(0.5); +this.body.width = 4; +this.body.height = 4; +this.tint = game.tinting.currentTint; + +} + +update(){ +this.rotation += 0.1 * this.game.time.physicsElapsedMS; +} +fire(velX, velY){ +this.killEvent = this.game.time.events.add(BULLET_LIFETIME_MS, () =>{ +this.kill(); +}); +this.body.velocity.x = BULLET_MAIN_VELOCITY * velX; +this.body.velocity.y = BULLET_MAIN_VELOCITY * velY; +} + +kill() { +super.kill(); +this.game.time.events.remove(this.killEvent); +} + +} \ No newline at end of file From 3391329379e5d08b098e94f3be8424e7712e50e8 Mon Sep 17 00:00:00 2001 From: labelled Date: Fri, 15 Apr 2016 10:34:04 +0100 Subject: [PATCH 4/7] Added my enemy into waves I have added my enemy into some of the waves in the game. --- src/data/wavesData.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/data/wavesData.yaml b/src/data/wavesData.yaml index 539f49d..459277a 100644 --- a/src/data/wavesData.yaml +++ b/src/data/wavesData.yaml @@ -30,20 +30,24 @@ - h: 15 e: 8 + r: 1 - g: 15 e: 8 a: 6 h: 4 + r: 2 - g: 20 e: 10 a: 4 h: 6 + r: 3 - g: 25 e: 10 a: 8 + r: 4 - g: 25 e: 10 From e16bebed10878a6490e26cd95c93ef85e86ff4a1 Mon Sep 17 00:00:00 2001 From: labelled Date: Fri, 15 Apr 2016 10:40:03 +0100 Subject: [PATCH 5/7] Added ranger shooting Added the properties of my enemy the ranger shooting in this script --- src/plugins/shooting.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/plugins/shooting.js b/src/plugins/shooting.js index e025a35..90a8bb5 100644 --- a/src/plugins/shooting.js +++ b/src/plugins/shooting.js @@ -17,6 +17,7 @@ export default class Shooting { this.playerBullets = this.game.add.group(); this.enforcerBullets = this.game.add.group(); + this.rangerBullets = this.game.add.group(); this.spears = this.game.add.group(); for (let x = 0; x < NUM_BULLETS; x++) { let bullet = new Bullet(this.game, 0, 0); @@ -27,7 +28,11 @@ export default class Shooting { enforcerBullet.alive = enforcerBullet.exists = enforcerBullet.visible = false; this.enforcerBullets.add(enforcerBullet); - let spear = new Spear(this.game, 0, 0); + let rangerBullet = new rangerBullet(this.game, 0, 0); + rangerBullet.alive = rangerBullet.exists = rangerBullet.visible = false; + this.rangerBullets.add(rangerBullet); + + let spear = new Spear(this.game, 0, 0); spear.alive = spear.exists = spear.visible = false; this.spears.add(spear); } @@ -35,9 +40,11 @@ export default class Shooting { this.game.waves.onTransition.add(() => { this.playerBullets.callAll('kill'); this.enforcerBullets.callAll('kill'); + this.rangerBullets.callAll('kill'); this.spears.callAll('kill'); // Set tint on bullets and spears. this.enforcerBullets.setAll('tint', this.game.tinting.currentTint); + this.rangerBullets.setAll('tint', this.game.tinting.currentTint); this.spears.setAll('tint', this.game.tinting.currentTint); }); } @@ -63,6 +70,15 @@ export default class Shooting { } } + rangerShoot(sx, sy, vx, vy) { + let bullet = this.rangerBullets.getFirstExists(false); + if (bullet) { + bullet.reset(sx, sy); + bullet.fire(vx, vy); + //this.enforcerShootSound.play(); + } + } + spearWarn() { this.spearWarnSound.play(); } @@ -87,6 +103,13 @@ export default class Shooting { this.game.physics.arcade.overlap(player, this.spears, this.onEnforcerBullet, null, this); } } + + let player = this.game.player; + if (player) { + this.game.physics.arcade.overlap(player, this.rangerBullets, this.onRangerBullet, null, this); + this.game.physics.arcade.overlap(player, this.spears, this.onRangerBullet, null, this); + } + } onProcess(enemy) { return enemy && enemy.alive; From dd35bd48cebbd51819a24f970beb966ee2e8c2a0 Mon Sep 17 00:00:00 2001 From: labelled Date: Fri, 15 Apr 2016 10:42:59 +0100 Subject: [PATCH 6/7] Added ranger into wave script Added my enemy ranger into the wave script. --- src/plugins/waves.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/waves.js b/src/plugins/waves.js index eeddeb0..b4fcede 100644 --- a/src/plugins/waves.js +++ b/src/plugins/waves.js @@ -75,6 +75,16 @@ export default class Waves { this.loaded = true; }); } + + for (let i = 0; i < wave.r; i++) { + let ranger = new Ranger(this.game, this.game.world.randomX, this.game.world.randomY); + this.enemiesGroup.add(ranger); + this.game.spawn.startSpawn(ranger, () => { + this.loading = false; + this.loaded = true; + }); + } + for (let i = 0; i < wave.a; i++) { let assassin = new Assassin(this.game, this.game.world.randomX, this.game.world.randomY); this.enemiesGroup.add(assassin); From 4654a384c9dbe7ab8215788ad09c5019feed65ae Mon Sep 17 00:00:00 2001 From: labelled Date: Fri, 15 Apr 2016 10:47:06 +0100 Subject: [PATCH 7/7] Added my two images into here Adding both of my images of the enemy and the beam image into the pre load. --- src/states/preload.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/states/preload.js b/src/states/preload.js index 4a07aa2..b9d97ec 100644 --- a/src/states/preload.js +++ b/src/states/preload.js @@ -17,7 +17,9 @@ export default class Preload extends Phaser.State { this.game.load.image('button', require('../../media/images/button.png'), 240, 80); this.game.load.image('phaserLogo', require('../../media/images/Phaser-Logo-Small.png'), 382, 331); this.game.load.image('drhayesLogo', require('../../media/images/drhayes.png'), 552, 586); - + this.game.load.image('blueenemy', require('../../media/images/blueenemy.png'), 32,32); + this.game.load.image('blueenemybeam', require('../../media/images/blueenemybeam.png'), 32,32); + this.game.load.audio('shoot', require('../../media/sounds/shoot.mp3')); this.game.load.audio('smallBoom', require('../../media/sounds/smallBoom.mp3')); this.game.load.audio('mediumBoom', require('../../media/sounds/mediumBoom.mp3'));