From 73eb9fbf5202ac2f76970c9847a3023484d2aad7 Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Sat, 26 Jul 2014 23:55:24 +0200 Subject: [PATCH] Removed debug traces and started working on a tutorial overlay --- src/Lives.hx | 2 -- src/MainScene.hx | 2 ++ src/Overlay.hx | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ src/Score.hx | 1 + src/Spawner.hx | 27 +++++++++++++++---------- 5 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 src/Overlay.hx diff --git a/src/Lives.hx b/src/Lives.hx index 681be1f..b456de0 100644 --- a/src/Lives.hx +++ b/src/Lives.hx @@ -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; diff --git a/src/MainScene.hx b/src/MainScene.hx index ffc9db0..0f417bf 100644 --- a/src/MainScene.hx +++ b/src/MainScene.hx @@ -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); } diff --git a/src/Overlay.hx b/src/Overlay.hx new file mode 100644 index 0000000..8e4f501 --- /dev/null +++ b/src/Overlay.hx @@ -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; + +} \ No newline at end of file diff --git a/src/Score.hx b/src/Score.hx index c816466..3951835 100644 --- a/src/Score.hx +++ b/src/Score.hx @@ -23,6 +23,7 @@ class Score extends Entity { public function add(x:Int) { score += x; + #if debug score += 10000; #end scoreText.text = "$" + score; } diff --git a/src/Spawner.hx b/src/Spawner.hx index f21dfdd..54bedc6 100644 --- a/src/Spawner.hx +++ b/src/Spawner.hx @@ -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 = []; var bosses:Array = []; + var overlay:Array = []; + 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; + } } }