Removed debug traces and started working on a tutorial overlay

This commit is contained in:
Bram van der Veen 2014-07-26 23:55:24 +02:00
parent 9e023b1257
commit 73eb9fbf52
5 changed files with 71 additions and 12 deletions

View file

@ -20,8 +20,6 @@ class Lives extends Entity {
if (Save.load().ship_type == 1) {maxDamage++;};
trace(maxDamage);
liveBar = Image.createRect(Math.floor(baseSprite.width * .75), 10, 0x00FF00);
liveBar.y += 65;

View file

@ -9,6 +9,7 @@ import Button;
import Enemy;
import Lives;
import Score;
import Overlay;
class MainScene extends Scene
{
@ -38,6 +39,7 @@ class MainScene extends Scene
add(lives);
add(score);
add(spawner);
add(new Overlay());
music.play(.1, 0, true);
}

51
src/Overlay.hx Normal file
View file

@ -0,0 +1,51 @@
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.HXP;
import com.haxepunk.graphics.Text;
class Overlay extends Entity {
public function new() {
super(HXP.halfWidth, HXP.halfHeight);
overlay = Image.createRect(HXP.width, HXP.height, 0x000000, 0.8);
this.centerOrigin();
this.addGraphic(overlay);
overlay.centerOrigin();
this.layer = -10;
//Init pickups
var thingy:Image = new Image("graphics/things_gold.png");
var star:Image = new Image("graphics/star_gold.png");
var shield:Image = new Image("graphics/shield_gold.png");
thingy.centerOrigin(); star.centerOrigin(); shield.centerOrigin();
thingy.y = star.y = shield.y = -400;
thingy.x -= 300; star.x -= 250; shield.x -= 200;
shield.scale = thingy.scale = star.scale = 1.5;
var pickupText:Text = new Text("Pick up these things for repairs,\nstars for money,\nshield for shielding from damage.");
pickupText.y = -400; pickupText.x += 70; pickupText.size = 25; pickupText.centerOrigin();
this.addGraphic(thingy); this.addGraphic(star); this.addGraphic(shield); this.addGraphic(pickupText);
//Init asteroids
var meteor:Image = new Image("graphics/meteorBrown_big1.png");
meteor.y -= 200; meteor.x -= 300; this.addGraphic(meteor);
var meteorText:Text = new Text("Avoid these, they'll kill you.");
meteorText.size = 25; meteorText.centerOrigin(); this.addGraphic(meteorText); meteorText.y -= 170; meteorText.x += 70;
//Init enemies
var enemy:Image = new Image("graphics/enemyGreen1.png");
enemy.x -= 300; this.addGraphic(enemy);
var enemyText:Text = new Text("These guys 'll try to shoot you,\nshoot back.");
enemyText.x += 70; enemyText.y += 50; enemyText.size = 25; enemyText.centerOrigin(); this.addGraphic(enemyText);
//Go to the store
var dollar:Text = new Text("$");
}
private var overlay:Image;
}

View file

@ -23,6 +23,7 @@ class Score extends Entity {
public function add(x:Int) {
score += x;
#if debug score += 10000; #end
scoreText.text = "$" + score;
}

View file

@ -6,6 +6,7 @@ import Boss;
import Star;
import Pickup;
import Asteroid;
import Overlay;
class Spawner extends Entity {
@ -17,10 +18,13 @@ class Spawner extends Entity {
enemyTimer -= HXP.elapsed;
var enemies:Array<Enemy> = [];
var bosses:Array<Boss> = [];
var overlay:Array<Overlay> = [];
this.scene.getClass(Enemy, enemies);
this.scene.getClass(Boss, bosses);
this.scene.getClass(Overlay, overlay);
if (level != 4) {
if (level != 4 && overlay.length == 0) {
if (enemyType == 6) {sublevel++; enemyType = 1;}
if (enemies.length < 1 && sublevel < 2) {
@ -48,7 +52,7 @@ class Spawner extends Entity {
level++; enemyType = 1; sublevel = 0; trace("Next level!");
}
}
else {
else if (overlay.length == 0) {
trace("YOU BEAT THE GAME!");
}
@ -57,19 +61,22 @@ class Spawner extends Entity {
spawnAsteroidTime -= HXP.elapsed;
spawnPickupTime -= HXP.elapsed;
if (spawnAsteroidTime < 0) {
this.scene.add(new Asteroid(HXP.width * Math.random(), -16));
spawnAsteroidTime = .5;
}
if (spawnStarTime < 0) {
this.scene.add(new Star(HXP.width * Math.random()));
spawnStarTime = .5;
}
if (spawnPickupTime < 0) {
this.scene.add(new Pickup(HXP.width * Math.random(), -50));
spawnPickupTime = 5 * Math.random() + 5;
if (overlay.length == 0) {
if (spawnAsteroidTime < 0) {
this.scene.add(new Asteroid(HXP.width * Math.random(), -16));
spawnAsteroidTime = .5;
}
if (spawnPickupTime < 0) {
this.scene.add(new Pickup(HXP.width * Math.random(), -50));
spawnPickupTime = 5 * Math.random() + 5;
}
}
}