Added different types of lasers and fixed bugs

This commit is contained in:
Bram van der Veen 2014-07-16 23:03:26 +02:00
parent b255f61c6d
commit 6b4c4a452d
7 changed files with 85 additions and 35 deletions

View file

@ -7,6 +7,8 @@ import com.haxepunk.HXP;
import Enemy; import Enemy;
import Explosion; import Explosion;
import Spawner; import Spawner;
import Bullet;
import Save;
class Boss extends Entity { class Boss extends Entity {
@ -89,7 +91,13 @@ class Boss extends Entity {
var bullet:Entity = this.collide("bullet", this.x, this.y); var bullet:Entity = this.collide("bullet", this.x, this.y);
if (bullet != null) { 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); this.scene.remove(bullet);
} }
} }
@ -104,10 +112,11 @@ class Boss extends Entity {
]; ];
private var color:Int; private var color:Int;
private var health:Int; private var health:Float;
private var originalHealth:Int; private var originalHealth:Float;
private var healthBar:Image; private var healthBar:Image;
private var healthBarBackground:Image; private var healthBarBackground:Image;
private var damage:Float;
private var maxEnemies:Int; private var maxEnemies:Int;
private var canSpawn:Bool = false; private var canSpawn:Bool = false;

View file

@ -4,11 +4,13 @@ import com.haxepunk.HXP;
class Bullet extends Entity { class Bullet extends Entity {
public function new(x:Float, y:Float) { public function new(x:Float, y:Float, ?isHeavyLaser:Bool) {
super(x, y); super(x, y);
laser1 = new Image("graphics/laserGreen04.png"); which = Save.load().laser;
laser2 = new Image("graphics/laserGreen12.png");
laser1 = new Image(laser[which][0]);
laser2 = new Image(laser[which][1]);
graphic = laser1; graphic = laser1;
@ -41,8 +43,25 @@ class Bullet extends Entity {
} }
} }
private var laser:Array<Array<String>> = [
[
"graphics/laserGreen04.png",
"graphics/laserGreen12.png"
],
[
"graphics/laserGreen10.png",
"graphics/laserGreen06.png"
],
[
"graphics/laserBlue02.png",
"graphics/laserBlue06.png"
]
];
private var laser1:Image; private var laser1:Image;
private var laser2:Image; private var laser2:Image;
public var which:Int;
private var timer:Float = .5; private var timer:Float = .5;
} }

View file

@ -6,6 +6,7 @@ import com.haxepunk.Sfx;
import Player; import Player;
import Score; import Score;
import EnemyBullet; import EnemyBullet;
import Save;
class Enemy extends Entity { class Enemy extends Entity {
@ -139,7 +140,13 @@ class Enemy extends Entity {
var bullet:Entity = collide("bullet", this.x, this.y); var bullet:Entity = collide("bullet", this.x, this.y);
if (bullet != null) { 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<Score> = []; var score:Array<Score> = [];
this.scene.getClass(Score, score); this.scene.getClass(Score, score);
@ -148,7 +155,7 @@ class Enemy extends Entity {
this.scene.remove(bullet); this.scene.remove(bullet);
} }
if (health == 0) { if (health <= 0) {
die(); die();
} }
} }
@ -175,10 +182,11 @@ class Enemy extends Entity {
private var color:Int; private var color:Int;
private var enemyType:Int; private var enemyType:Int;
private var health:Int; private var health:Float;
private var originalHealth:Int; private var originalHealth:Float;
private var dying:Bool = false; private var dying:Bool = false;
private var died:Bool = false; private var died:Bool = false;
private var damage:Float;
private var arr:Array<Float>; private var arr:Array<Float>;
private var antX:Float; private var antX:Float;

View file

@ -11,9 +11,9 @@ class Lives extends Entity {
baseSprite = new Image("graphics/" + Save.load().ship); baseSprite = new Image("graphics/" + Save.load().ship);
sprite = [ sprite = [
baseSprite, baseSprite,
new Image("graphics/playerShip" + (Save.load().ship_type + 1) + "_damage1.png"), new Image("graphics/playerShip" + (Save.load().ship_type) + "_damage1.png"),
new Image("graphics/playerShip" + (Save.load().ship_type + 1) + "_damage2.png"), new Image("graphics/playerShip" + (Save.load().ship_type) + "_damage2.png"),
new Image("graphics/playerShip" + (Save.load().ship_type + 1) + "_damage3.png") new Image("graphics/playerShip" + (Save.load().ship_type) + "_damage3.png")
]; ];
maxDamage = Save.load().ship_type + Save.load().ship_color; maxDamage = Save.load().ship_type + Save.load().ship_color;

View file

@ -21,13 +21,11 @@ class Player extends Entity {
baseSprite = new Image("graphics/" + Save.load().ship); baseSprite = new Image("graphics/" + Save.load().ship);
if (Save.load().ship_type == 1) if (Save.load().ship_type == 1)
moveSpeed = 10;
else if (Save.load().ship_type == 2)
moveSpeed = 7; moveSpeed = 7;
else else if (Save.load().ship_type == 2)
moveSpeed = 5; moveSpeed = 5;
else
trace(moveSpeed + ", " + Save.load().ship_type); moveSpeed = 4;
shield = new Image("graphics/shield1.png"); shield = new Image("graphics/shield1.png");

View file

@ -18,7 +18,7 @@ class Save extends Entity {
"ship" : Data.readString("ship" , "playerShip3_green.png"), "ship" : Data.readString("ship" , "playerShip3_green.png"),
"ship_type" : Data.readInt("ship_type", 3), "ship_type" : Data.readInt("ship_type", 3),
"ship_color" : Data.readInt("ship_color", 1), "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), "has_heavy_laser" : Data.readBool("heavy_laser", false),
"money" : Data.readInt("money", 1000) "money" : Data.readInt("money", 1000)
}; };

View file

@ -77,9 +77,24 @@ class StoreItem extends Entity {
private function buy() { private function buy() {
var save = Save.load(); var save = Save.load();
if (save.money >= prices[which][currentSprite]) { if (save.money >= prices[which][currentSprite]) {
Save.save("ship", items[which][currentSprite]); if (which <= 2) {
Save.save("ship_type", which); if (which == 0)
Save.save("ship_color", currentSprite); 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]); Save.save("money", save.money - prices[which][currentSprite]);
trace("Bought something"); trace("Bought something");
} }
@ -167,25 +182,26 @@ class StoreItem extends Entity {
private var prices:Array<Array<Int>> = [ private var prices:Array<Array<Int>> = [
[ [
50000, 50000,
70000,
90000
],
[
100000,
120000,
140000
],
[
150000, 150000,
200000, 200000
300000 ],
[
250000,
300000,
350000
],
[
400000,
450000,
500000
], ],
[ [
50000, 50000,
100000 100000,
150000
], ],
[ [
150000 200000
] ]
]; ];