diff --git a/src/Boss.hx b/src/Boss.hx index be85b91..21e65dc 100644 --- a/src/Boss.hx +++ b/src/Boss.hx @@ -7,6 +7,8 @@ import com.haxepunk.HXP; import Enemy; import Explosion; import Spawner; +import Bullet; +import Save; class Boss extends Entity { @@ -89,7 +91,13 @@ class Boss extends Entity { var bullet:Entity = this.collide("bullet", this.x, this.y); if (bullet != null) { - this.health -= 1; + if (Save.load().laser == 0) + damage = 1; + else if (Save.load().laser == 1) + damage = 1.25; + else if (Save.load().laser == 2) + damage = 1.5; + this.health -= damage; this.scene.remove(bullet); } } @@ -104,10 +112,11 @@ class Boss extends Entity { ]; private var color:Int; - private var health:Int; - private var originalHealth:Int; + private var health:Float; + private var originalHealth:Float; private var healthBar:Image; private var healthBarBackground:Image; + private var damage:Float; private var maxEnemies:Int; private var canSpawn:Bool = false; diff --git a/src/Bullet.hx b/src/Bullet.hx index 4ce0945..d603216 100644 --- a/src/Bullet.hx +++ b/src/Bullet.hx @@ -4,11 +4,13 @@ import com.haxepunk.HXP; class Bullet extends Entity { - public function new(x:Float, y:Float) { + public function new(x:Float, y:Float, ?isHeavyLaser:Bool) { super(x, y); - laser1 = new Image("graphics/laserGreen04.png"); - laser2 = new Image("graphics/laserGreen12.png"); + which = Save.load().laser; + + laser1 = new Image(laser[which][0]); + laser2 = new Image(laser[which][1]); graphic = laser1; @@ -41,8 +43,25 @@ class Bullet extends Entity { } } + private var laser:Array> = [ + [ + "graphics/laserGreen04.png", + "graphics/laserGreen12.png" + ], + [ + "graphics/laserGreen10.png", + "graphics/laserGreen06.png" + ], + [ + "graphics/laserBlue02.png", + "graphics/laserBlue06.png" + ] + ]; + private var laser1:Image; private var laser2:Image; + public var which:Int; + private var timer:Float = .5; } \ No newline at end of file diff --git a/src/Enemy.hx b/src/Enemy.hx index 9a1260f..c5cb073 100644 --- a/src/Enemy.hx +++ b/src/Enemy.hx @@ -6,6 +6,7 @@ import com.haxepunk.Sfx; import Player; import Score; import EnemyBullet; +import Save; class Enemy extends Entity { @@ -139,7 +140,13 @@ class Enemy extends Entity { var bullet:Entity = collide("bullet", this.x, this.y); if (bullet != null) { - health -= 1; + if (Save.load().laser == 0) + damage = 1; + else if (Save.load().laser == 1) + damage = 1.25; + else if (Save.load().laser == 2) + damage = 1.5; + health -= damage; var score:Array = []; this.scene.getClass(Score, score); @@ -148,7 +155,7 @@ class Enemy extends Entity { this.scene.remove(bullet); } - if (health == 0) { + if (health <= 0) { die(); } } @@ -175,10 +182,11 @@ class Enemy extends Entity { private var color:Int; private var enemyType:Int; - private var health:Int; - private var originalHealth:Int; + private var health:Float; + private var originalHealth:Float; private var dying:Bool = false; private var died:Bool = false; + private var damage:Float; private var arr:Array; private var antX:Float; diff --git a/src/Lives.hx b/src/Lives.hx index 2b95c84..665e3b7 100644 --- a/src/Lives.hx +++ b/src/Lives.hx @@ -11,9 +11,9 @@ class Lives extends Entity { baseSprite = new Image("graphics/" + Save.load().ship); sprite = [ baseSprite, - new Image("graphics/playerShip" + (Save.load().ship_type + 1) + "_damage1.png"), - new Image("graphics/playerShip" + (Save.load().ship_type + 1) + "_damage2.png"), - new Image("graphics/playerShip" + (Save.load().ship_type + 1) + "_damage3.png") + new Image("graphics/playerShip" + (Save.load().ship_type) + "_damage1.png"), + new Image("graphics/playerShip" + (Save.load().ship_type) + "_damage2.png"), + new Image("graphics/playerShip" + (Save.load().ship_type) + "_damage3.png") ]; maxDamage = Save.load().ship_type + Save.load().ship_color; diff --git a/src/Player.hx b/src/Player.hx index f5157a3..de68804 100644 --- a/src/Player.hx +++ b/src/Player.hx @@ -21,13 +21,11 @@ class Player extends Entity { baseSprite = new Image("graphics/" + Save.load().ship); if (Save.load().ship_type == 1) - moveSpeed = 10; - else if (Save.load().ship_type == 2) moveSpeed = 7; - else + else if (Save.load().ship_type == 2) moveSpeed = 5; - - trace(moveSpeed + ", " + Save.load().ship_type); + else + moveSpeed = 4; shield = new Image("graphics/shield1.png"); diff --git a/src/Save.hx b/src/Save.hx index 1986981..1a73a7e 100644 --- a/src/Save.hx +++ b/src/Save.hx @@ -18,7 +18,7 @@ class Save extends Entity { "ship" : Data.readString("ship" , "playerShip3_green.png"), "ship_type" : Data.readInt("ship_type", 3), "ship_color" : Data.readInt("ship_color", 1), - "laser" : Data.readString("laser", "laserGreen04.png"), + "laser" : Data.readInt("laser", 0), "has_heavy_laser" : Data.readBool("heavy_laser", false), "money" : Data.readInt("money", 1000) }; diff --git a/src/StoreItem.hx b/src/StoreItem.hx index 4859e21..7b1920e 100644 --- a/src/StoreItem.hx +++ b/src/StoreItem.hx @@ -77,9 +77,24 @@ class StoreItem extends Entity { private function buy() { var save = Save.load(); if (save.money >= prices[which][currentSprite]) { - Save.save("ship", items[which][currentSprite]); - Save.save("ship_type", which); - Save.save("ship_color", currentSprite); + if (which <= 2) { + if (which == 0) + Save.save("ship_type", 3); + else if (which == 1) + Save.save("ship_type", 1); + else + Save.save("ship_type", 2); + + Save.save("ship", items[which][currentSprite]); + Save.save("ship_color", currentSprite); + } + else { + if (which == 4) + Save.save("heavy_laser", true); + else + Save.save("laser", currentSprite); + } + Save.save("money", save.money - prices[which][currentSprite]); trace("Bought something"); } @@ -167,25 +182,26 @@ class StoreItem extends Entity { private var prices:Array> = [ [ 50000, - 70000, - 90000 - ], - [ - 100000, - 120000, - 140000 - ], - [ 150000, - 200000, - 300000 + 200000 + ], + [ + 250000, + 300000, + 350000 + ], + [ + 400000, + 450000, + 500000 ], [ 50000, - 100000 + 100000, + 150000 ], [ - 150000 + 200000 ] ];