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 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;

View file

@ -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<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 laser2:Image;
public var which:Int;
private var timer:Float = .5;
}

View file

@ -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<Score> = [];
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<Float>;
private var antX:Float;

View file

@ -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;

View file

@ -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");

View file

@ -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)
};

View file

@ -77,9 +77,24 @@ class StoreItem extends Entity {
private function buy() {
var save = Save.load();
if (save.money >= prices[which][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_type", which);
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<Array<Int>> = [
[
50000,
70000,
90000
],
[
100000,
120000,
140000
],
[
150000,
200000,
300000
200000
],
[
250000,
300000,
350000
],
[
400000,
450000,
500000
],
[
50000,
100000
100000,
150000
],
[
150000
200000
]
];