Added some more features, made the lives sync with the plane that was being used.

This commit is contained in:
Bram van der Veen 2014-07-16 16:53:23 +02:00
parent e2f94102d4
commit b255f61c6d
5 changed files with 36 additions and 9 deletions

View file

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

View file

@ -2,12 +2,14 @@ import com.haxepunk.Scene;
import com.haxepunk.HXP; import com.haxepunk.HXP;
import com.haxepunk.graphics.Text; import com.haxepunk.graphics.Text;
import com.haxepunk.graphics.Backdrop; import com.haxepunk.graphics.Backdrop;
import com.haxepunk.utils.Input;
import openfl.Assets; import openfl.Assets;
import MenuButton; import MenuButton;
import Title; import Title;
import Spawner; import Spawner;
import MainScene; import MainScene;
import Save;
class MenuScene extends Scene { class MenuScene extends Scene {
@ -15,7 +17,7 @@ class MenuScene extends Scene {
backdrop = new Backdrop("graphics/darkPurple.png", true, true); backdrop = new Backdrop("graphics/darkPurple.png", true, true);
var play = new MenuButton(HXP.width / 2, HXP.height / 2, "Play!"); var play = new MenuButton(HXP.width / 2, HXP.height / 2, "Play!");
var title = new Title(); var title = new Title();
var copy = new Text("By Bram \"96AA48\" van der Veen, 2014\nGraphics and Sfx by Kenney\nMusic by Jensan", HXP.width / 2, HXP.height - 50, {align: "center"}); copy = new Text("By Bram \"96AA48\" van der Veen, 2014\nGraphics and Sfx by Kenney\nMusic by Jensan", HXP.width / 2, HXP.height - 50, {align: "center"});
var spawner = new Spawner(); var spawner = new Spawner();
copy.size = 22; copy.size = 22;
@ -39,7 +41,14 @@ class MenuScene extends Scene {
public override function update() { public override function update() {
super.update(); super.update();
backdrop.y += 1; backdrop.y += 1;
if (Input.mousePressed) {
if ((Input.mouseY > HXP.height - 200)) {
Save.reset();
}
}
} }
private var backdrop:Backdrop; private var backdrop:Backdrop;
private var copy:Text;
} }

View file

@ -114,7 +114,7 @@ class Player extends Entity {
var score:Array<Score> = []; var score:Array<Score> = [];
this.scene.getClass(Score, score); this.scene.getClass(Score, score);
score[0].rem(250); score[0].rem(300);
var ship:Int = Save.load().ship_type; var ship:Int = Save.load().ship_type;
if (ship == 3){ if (ship == 3){
@ -149,8 +149,9 @@ class Player extends Entity {
Save.save("money", score[0].score); Save.save("money", score[0].score);
this.scene.addGraphic(txt); this.scene.addGraphic(txt);
this.scene.add(new MenuButton(HXP.halfWidth, HXP.halfHeight - 50, "Store")); this.scene.add(new MenuButton(HXP.halfWidth, HXP.halfHeight - 50, "Retry"));
this.scene.add(new MenuButton(HXP.halfWidth, HXP.halfHeight + 50, "Menu")); this.scene.add(new MenuButton(HXP.halfWidth, HXP.halfHeight + 50, "Store"));
this.scene.add(new MenuButton(HXP.halfWidth, HXP.halfHeight + 150, "Menu"));
} }
public override function update() { public override function update() {

View file

@ -5,7 +5,6 @@ class Save extends Entity {
public function new() { public function new() {
super(); super();
Data.load("save/savegame.save");
} }
public static function save(what:String, data:Dynamic) { public static function save(what:String, data:Dynamic) {
@ -14,6 +13,7 @@ class Save extends Entity {
} }
public static function load() { public static function load() {
Data.load("save/savegame.save");
var data = { var data = {
"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),
@ -26,4 +26,19 @@ class Save extends Entity {
return data; return data;
} }
public static function reset() {
Data.write("ship" , "playerShip3_green.png");
Data.write("ship_type", 3);
Data.write("ship_color", 1);
Data.write("laser", "laserGreen04.png");
Data.write("heavy_laser", false);
Data.write("money", 1000);
Data.save("save/savegame.save", true);
trace("Reset savefile");
}
} }

View file

@ -25,6 +25,8 @@ class StoreScene extends Scene {
this.add(new MenuButton(HXP.halfWidth - 220, HXP.height - 50, "Retry")); this.add(new MenuButton(HXP.halfWidth - 220, HXP.height - 50, "Retry"));
this.add(new MenuButton(HXP.halfWidth + 220, HXP.height - 50, "Menu")); this.add(new MenuButton(HXP.halfWidth + 220, HXP.height - 50, "Menu"));
Save.load();
} }
public override function update() { public override function update() {