From 870867863942a2873e4a6ff7b063d514d1a27ec8 Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Thu, 17 Jul 2014 01:59:44 +0200 Subject: [PATCH] Added/Fixed a lot of things : * added heavy laser * fixed enemies spawning together with level boss. * added new icon * added more stuff, can't remember. --- assets/HaxePunk.svg | 55 ++++++++++++++++++++++++++++++++++++++++++++- src/Boss.hx | 4 ++++ src/Bullet.hx | 33 +++++++++++++++++++++------ src/Enemy.hx | 4 ++++ src/Player.hx | 37 ++++++++++++++++++++++++------ src/Score.hx | 2 +- src/Spawner.hx | 4 ++-- 7 files changed, 121 insertions(+), 18 deletions(-) diff --git a/assets/HaxePunk.svg b/assets/HaxePunk.svg index 52513b2..7163309 100644 --- a/assets/HaxePunk.svg +++ b/assets/HaxePunk.svg @@ -1,2 +1,55 @@ - \ No newline at end of file +image/svg+xml \ No newline at end of file diff --git a/src/Boss.hx b/src/Boss.hx index 21e65dc..144e824 100644 --- a/src/Boss.hx +++ b/src/Boss.hx @@ -89,6 +89,7 @@ class Boss extends Entity { } var bullet:Entity = this.collide("bullet", this.x, this.y); + var heavybullet:Entity = this.collide("heavybullet", this.x, this.y); if (bullet != null) { if (Save.load().laser == 0) @@ -100,6 +101,9 @@ class Boss extends Entity { this.health -= damage; this.scene.remove(bullet); } + else if (heavybullet != null) { + this.health -= 2; + } } private var currentSprite:Image; diff --git a/src/Bullet.hx b/src/Bullet.hx index d603216..3e51952 100644 --- a/src/Bullet.hx +++ b/src/Bullet.hx @@ -4,13 +4,19 @@ import com.haxepunk.HXP; class Bullet extends Entity { - public function new(x:Float, y:Float, ?isHeavyLaser:Bool) { + public function new(x:Float, y:Float, ?heavylaser:Bool) { super(x, y); + isHeavyLaser = heavylaser; which = Save.load().laser; - - laser1 = new Image(laser[which][0]); - laser2 = new Image(laser[which][1]); + if (!isHeavyLaser) { + laser1 = new Image(laser[which][0]); + laser2 = new Image(laser[which][1]); + } + else { + laser1 = new Image("graphics/laserBlue15.png"); + laser2 = new Image("graphics/laserBlue16.png"); + } graphic = laser1; @@ -19,20 +25,31 @@ class Bullet extends Entity { laser2.centerOrigin(); this.centerOrigin(); - type = "bullet"; + if (!isHeavyLaser) { + type = "bullet"; + } + else { + layer = -4; + type = "heavybullet"; + + } } public override function update() { super.update(); - this.y -= 20; + this.y -= moveSpeed; timer -= HXP.elapsed; - if (collide("asteroid", this.x, this.y) != null) { + if (collide("asteroid", this.x, this.y) != null && !isHeavyLaser) { this.scene.remove(this); } + else if (collide("asteroid", this.x, this.y) != null && isHeavyLaser) { + if (this.moveSpeed > 5) + this.moveSpeed -= 2; + } if (timer < 0 || this.y < 200) { graphic = laser2; @@ -60,6 +77,8 @@ class Bullet extends Entity { private var laser1:Image; private var laser2:Image; + private var isHeavyLaser:Bool = false; + private var moveSpeed:Float = 20; public var which:Int; diff --git a/src/Enemy.hx b/src/Enemy.hx index c5cb073..fe1d3b5 100644 --- a/src/Enemy.hx +++ b/src/Enemy.hx @@ -138,6 +138,7 @@ class Enemy extends Entity { } var bullet:Entity = collide("bullet", this.x, this.y); + var heavybullet:Entity = this.collide("heavybullet", this.x, this.y); if (bullet != null) { if (Save.load().laser == 0) @@ -154,6 +155,9 @@ class Enemy extends Entity { this.scene.remove(bullet); } + else if (heavybullet != null) { + this.health -= 2; + } if (health <= 0) { die(); diff --git a/src/Player.hx b/src/Player.hx index de68804..2b39dac 100644 --- a/src/Player.hx +++ b/src/Player.hx @@ -21,11 +21,11 @@ class Player extends Entity { baseSprite = new Image("graphics/" + Save.load().ship); if (Save.load().ship_type == 1) - moveSpeed = 7; + moveSpeed = 9; else if (Save.load().ship_type == 2) - moveSpeed = 5; + moveSpeed = 7; else - moveSpeed = 4; + moveSpeed = 5; shield = new Image("graphics/shield1.png"); @@ -95,16 +95,27 @@ class Player extends Entity { this.y -= moveSpeed; } - if (Input.pressed("shoot")) { - shoot(); + if (Input.released("shoot")) { + if (holdShoot > .5 && Save.load().has_heavy_laser) { + heavyShoot(); + holdShoot = 0; + } + else { + shoot(); + holdShoot = 0; + } + } + + if (Input.check("shoot")) { + holdShoot += HXP.elapsed; } Input.touchPoints(onTouch); } private function onTouch(touch:Touch) { - if (touch.y < HXP.height - 100 && (touch.y > 700) && this.y > 0) - this.moveTowards(touch.x - (this.width / 2), touch.y - (this.height * 2), moveSpeed * 1.5); + if (!(touch.x < 100 && touch.y > HXP.height - 100) && this.y > 0) + this.moveTowards(touch.x, touch.y - (this.height * 2), moveSpeed); } public function shoot() { @@ -131,6 +142,17 @@ class Player extends Entity { } } + public function heavyShoot() { + if (this.y > 0) { + var score:Array = []; + this.scene.getClass(Score, score); + score[0].rem(1000); + + this.scene.add(new Bullet(this.x, this.y - this.height / 2, true)); + laser.play(); + } + } + public function die() { this.visible = false; var score:Array = []; @@ -223,6 +245,7 @@ class Player extends Entity { private var hitPause:Float = 0; private var animWait:Float = .75; private var currentAnim:Int = 0; + private var holdShoot:Float = 0; public var shielded:Bool = false; public var shieldTimer:Float = 1; diff --git a/src/Score.hx b/src/Score.hx index 339ebbe..c816466 100644 --- a/src/Score.hx +++ b/src/Score.hx @@ -16,7 +16,7 @@ class Score extends Entity { scoreText = new Text("$" + score, 0, 0, 0, 0, {size : 50, align : "center", color : 0xFFF000}); scoreText.font = Assets.getFont("font/kenpixel_mini_square.ttf").fontName; - layer = -3; + layer = -6; this.addGraphic(scoreText); } diff --git a/src/Spawner.hx b/src/Spawner.hx index fcd429f..f21dfdd 100644 --- a/src/Spawner.hx +++ b/src/Spawner.hx @@ -10,7 +10,7 @@ import Asteroid; class Spawner extends Entity { public function new() { - super(0,0); + super(); } public override function update() { @@ -39,7 +39,7 @@ class Spawner extends Entity { enemyTimer = 1; } - if (sublevel == 2 && !bossSpawned) { + if (sublevel == 2 && !bossSpawned && enemies.length == 0) { this.scene.add(new Boss(level)); bossSpawned = true; }