Added sounds and a LOT of other things.

This commit is contained in:
Bram van der Veen 2014-07-07 20:11:22 +02:00
parent 0efb5228ab
commit 84f214bc74
84 changed files with 344 additions and 32 deletions

5
.gitattributes vendored
View file

@ -1 +1,6 @@
/assets/graphics/Space[[:space:]]shooter.zip filter=lfs diff=lfs merge=lfs -text
/assets/audio/boss.mp3 filter=lfs diff=lfs merge=lfs -text
/assets/audio/boss.wav filter=lfs diff=lfs merge=lfs -text
/assets/audio/jingleSounds_Kenney.zip filter=lfs diff=lfs merge=lfs -text
/assets/audio/loop.mp3 filter=lfs diff=lfs merge=lfs -text
/assets/audio/loop.wav filter=lfs diff=lfs merge=lfs -text

BIN
assets/audio/boss.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/audio/boss.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/audio/highDown.mp3 Normal file

Binary file not shown.

BIN
assets/audio/highUp.mp3 Normal file

Binary file not shown.

BIN
assets/audio/jingleSounds_Kenney.zip (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/audio/laser1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser3.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser3.wav Normal file

Binary file not shown.

BIN
assets/audio/laser4.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser4.wav Normal file

Binary file not shown.

BIN
assets/audio/laser5.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser6.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser7.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser8.mp3 Normal file

Binary file not shown.

BIN
assets/audio/laser9.mp3 Normal file

Binary file not shown.

BIN
assets/audio/loop.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/audio/loop.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/audio/lowDown.mp3 Normal file

Binary file not shown.

BIN
assets/audio/lowRandom.mp3 Normal file

Binary file not shown.

Binary file not shown.

BIN
assets/audio/pepSound1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/pepSound2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/pepSound3.mp3 Normal file

Binary file not shown.

BIN
assets/audio/pepSound4.mp3 Normal file

Binary file not shown.

BIN
assets/audio/pepSound5.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaseJump1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaseJump2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaseJump3.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaseJump4.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaseJump5.mp3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/audio/phaserUp1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaserUp2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaserUp3.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaserUp4.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaserUp5.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaserUp6.mp3 Normal file

Binary file not shown.

BIN
assets/audio/phaserUp7.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp10.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp11.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp12.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp3.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp4.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp5.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp6.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp6.wav Normal file

Binary file not shown.

BIN
assets/audio/powerUp7.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp8.mp3 Normal file

Binary file not shown.

BIN
assets/audio/powerUp9.mp3 Normal file

Binary file not shown.

8
assets/audio/readme.txt Normal file
View file

@ -0,0 +1,8 @@
---
Digital SFX set by Kenney Vleugels (www.kenney.nl)
You may use these sounds in personal and commercial projects.
Credit (www.kenney.nl) would be nice but is not mandatory.
--

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/audio/threeTone1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/threeTone2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/tone1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/twoTone1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/twoTone2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/zap1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/zap2.mp3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/audio/zapTwoTone.mp3 Normal file

Binary file not shown.

Binary file not shown.

View file

@ -21,11 +21,10 @@ class Asteroid extends Entity {
graphic = sprite;
setHitbox(sprite.width - 15, sprite.height);
sprite.centerOrigin();
setHitbox(sprite.width, sprite.height);
type = "asteroid";
layer = -2;
@ -38,8 +37,8 @@ class Asteroid extends Entity {
this.scene.remove(this);
}
this.originX = Math.floor(sprite.width / 2);
this.originY = Math.floor(sprite.height / 2);
this.centerOrigin();
sprite.centerOrigin();
if (side > .5)
this.sprite.angle += angleSpeed;

View file

@ -1,9 +1,11 @@
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.HXP;
import com.haxepunk.Sfx;
import Player;
import Score;
import EnemyBullet;
class Enemy extends Entity {
@ -13,6 +15,12 @@ class Enemy extends Entity {
color = Math.floor(Math.random() * 4);
enemyType = Math.floor(Math.random() * 5) + 1;
#if flash
bulletSound = new Sfx("audio/laser3.mp3");
#else
bulletSound = new Sfx("audio/laser3.wav");
#end
sprite = new Image("graphics/" + enemies[color] + enemyType + ".png");
healthSprite = Image.createRect(sprite.width, 10, 0x00FF00);
@ -31,9 +39,8 @@ class Enemy extends Entity {
layer = -1;
}
private function assignLocation() {
if (enemyType <= 2) {
if (enemyType < 3) {
arr = [
Math.floor(Math.random() * (HXP.width - this.width)),
Math.floor(Math.random() * 400)
@ -76,8 +83,30 @@ class Enemy extends Entity {
return arr;
}
private function shoot() {
if (shootTimer < 0) {
if (enemyType != 3) {
this.scene.add(new EnemyBullet(this.x, this.y + this.height));
}
else {
this.scene.add(new EnemyBullet(this.x - 30, this.y + this.height));
this.scene.add(new EnemyBullet(this.x + 30, this.y + this.height));
}
if (enemyType == 4) {
shootTimer = 1;
}
else {
shootTimer = 5;
}
bulletSound.play();
}
}
public override function update() {
turnTimer -= HXP.elapsed;
shootTimer -= HXP.elapsed;
this.centerOrigin();
healthSprite.scaledWidth = (sprite.width / originalHealth) * health;
@ -92,10 +121,21 @@ class Enemy extends Entity {
turnTimer = 2;
else if (enemyType == 3 || enemyType == 4)
turnTimer = 1;
else if (enemyType == 1)
else if (enemyType == 1 || enemyType == 5)
turnTimer = .5;
}
if (enemyType > 2) {
if (Math.random() < .1 && shootTimer < 0) {
var player = this.scene.getInstance("player");
if (this.x > player.left && this.x < player.right) {
turnTimer = 1;
loc = [this.x, this.y];
shoot();
}
}
}
var bullet:Entity = collide("bullet", this.x, this.y);
if (bullet != null) {
@ -103,7 +143,7 @@ class Enemy extends Entity {
var score:Array<Score> = [];
this.scene.getClass(Score, score);
score[0].add(15);
score[0].add(1500);
this.scene.remove(bullet);
}
@ -121,6 +161,7 @@ class Enemy extends Entity {
private var sprite:Image;
private var healthSprite:Image;
private var bulletSound:Sfx;
private var color:Int;
private var enemyType:Int;
@ -131,6 +172,7 @@ class Enemy extends Entity {
private var antX:Float;
private var turnTimer:Float = 0;
private var shootTimer:Float = 0;
private var moveSpeed:Int = 10;
private var loc:Array<Float> = [];
}

46
src/EnemyBullet.hx Normal file
View file

@ -0,0 +1,46 @@
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.HXP;
class EnemyBullet extends Entity {
public function new (x:Float, y:Float) {
super(x, y);
sprite = [
new Image("graphics/laserRed14.png"),
new Image("graphics/laserRed16.png")
];
for (i in 0...sprite.length) {
sprite[i].angle = 180;
sprite[i].centerOrigin();
}
setHitboxTo(sprite[0]);
graphic = sprite[0];
type = "enemybullet";
}
public override function update() {
super.update();
timer -= HXP.elapsed;
this.centerOrigin();
this.y += 10;
if (timer < 0) {
graphic = sprite[1];
}
if (this.y > HXP.height) {
this.scene.remove(this);
}
}
private var sprite:Array<Image>;
private var timer:Float = .5;
}

View file

@ -15,17 +15,21 @@ class Lives extends Entity {
new Image("graphics/playerShip1_damage3.png")
];
liveBar = Image.createRect(Math.floor(baseSprite.width * .75), 10, 0x00FF00);
liveBar.y += 70;
baseSprite.scale = .75;
for (i in 0...sprite.length) {
sprite[i].scale = .75;
}
super(HXP.width - (baseSprite.width * .75 + 20), HXP.height - (baseSprite.height * .75 + 20));
super(HXP.width - (baseSprite.width * .75 + 20), HXP.height - (baseSprite.height * .75 + 50));
graphic = baseSprite;
this.addGraphic(sprite[0]);
this.addGraphic(liveBar);
damage = 0;
@ -33,10 +37,16 @@ class Lives extends Entity {
}
public inline function addDamage() {damage++;}
public inline function remDamage() {if (damage != 0) damage--;}
public override function update() {
graphic = baseSprite;
this.addGraphic(sprite[damage]);
liveBar.scaledWidth = (liveBar.width / 4) * (4 - damage);
this.addGraphic(liveBar);
if (damage > 3) {
var player:Array<Player> = [];
this.scene.getClass(Player, player);
@ -49,6 +59,7 @@ class Lives extends Entity {
private var sprite:Array<Image> = [];
private var baseSprite:Image;
private var liveBar:Image;
private var damage:Int;
}

View file

@ -1,6 +1,7 @@
import com.haxepunk.Scene;
import com.haxepunk.HXP;
import com.haxepunk.graphics.Backdrop;
import com.haxepunk.Sfx;
import Spawner;
import Player;
@ -17,9 +18,15 @@ class MainScene extends Scene
var player = new Player();
var button = new Button();
var spawner = new Spawner();
var enemy = new Enemy(160, 0);
var enemy = new Enemy(-160, 0);
var lives = new Lives();
var score = new Score();
#if flash
music = new Sfx("audio/loop.mp3");
#else
music = new Sfx("audio/loop.wav");
#end
addGraphic(backdrop);
@ -31,7 +38,13 @@ class MainScene extends Scene
add(lives);
add(score);
add(spawner);
music.play(.1, 0, true);
}
public override function end() {
this.removeAll();
music.stop();
this.update();
}
public override function update() {
@ -40,4 +53,5 @@ class MainScene extends Scene
}
private var backdrop:Backdrop;
private var music:Sfx;
}

View file

@ -44,9 +44,11 @@ class MenuButton extends Entity {
if (Input.mouseReleased) {
if ((Input.mouseX > this.left && Input.mouseX < this.right) && (Input.mouseY > this.top && Input.mouseY < this.bottom)) {
if (this.text.text != "Menu") {
HXP.scene = null;
HXP.scene = new MainScene();
}
else {
HXP.scene = null;
HXP.scene = new MenuScene();
}
}
@ -54,9 +56,11 @@ class MenuButton extends Entity {
if (Input.check("enter")) {
if (this.text.text != "Menu") {
HXP.scene = null;
HXP.scene = new MainScene();
}
else {
HXP.scene = null;
HXP.scene = new MenuScene();
}
}
@ -65,9 +69,11 @@ class MenuButton extends Entity {
private function onTouch(touch:Touch) {
if ((touch.x > this.left && touch.x < this.right) && (touch.y > this.top && touch.y < this.bottom)) {
if (this.text.text != "Menu") {
HXP.scene = null;
HXP.scene = new MainScene();
}
else {
HXP.scene = null;
HXP.scene = new MenuScene();
}
}

View file

@ -31,6 +31,11 @@ class MenuScene extends Scene {
addGraphic(copy);
}
public override function end() {
this.removeAll();
update();
}
public override function update() {
super.update();
backdrop.y += 1;

108
src/Pickup.hx Normal file
View file

@ -0,0 +1,108 @@
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.HXP;
import com.haxepunk.Sfx;
import Score;
import Lives;
class Pickup extends Entity {
public function new (x:Float, y:Float) {
super(x, y);
#if flash
sound = new Sfx("audio/powerUp6.mp3");
#else
sound = new Sfx("audio/powerUp6.wav");
#end
var tempRand = .9 /*Math.random()*/;
if (tempRand < .15)
randType = 1;
else if (tempRand > .15 && tempRand < .80)
randType = 2;
else
randType = 0;
rand = Math.floor(Math.random() * 3);
graphic = currentSprite = sprites[randType][rand];
if (Math.random() > .5)
turnSpeed = -1 * (Math.random() * 4);
else
turnSpeed = 1 * (Math.random() * 4);
setHitboxTo(currentSprite);
}
public override function update () {
this.y += (Math.random() * 3) + 6;
this.centerOrigin();
currentSprite.centerOrigin();
currentSprite.angle += turnSpeed;
if (this.y > HXP.height) {
this.scene.remove(this);
}
if (collide("player", this.x, this.y) != null) {
var score:Array<Score> = [];
this.scene.getClass(Score, score);
//Shield pickup
if (this.randType == 0) {
var player:Array<Player> = [];
this.scene.getClass(Player, player);
player[0].shielded = true;
player[0].shieldTimer = (rand + 1) * 3;
}
//"things" pickup
else if (this.randType == 1) {
var lives:Array<Lives> = [];
this.scene.getClass(Lives, lives);
for(i in 0...rand + 1)
lives[0].remDamage();
}
//Money pickup
else if (this.randType == 2) {
score[0].add(1000 * this.randType);
}
sound.play();
this.scene.remove(this);
}
}
private var sprites:Array<Array<Image>> = [
[
new Image("graphics/shield_bronze.png"),
new Image("graphics/shield_silver.png"),
new Image("graphics/shield_gold.png")
],
[
new Image("graphics/things_bronze.png"),
new Image("graphics/things_silver.png"),
new Image("graphics/things_gold.png")
],
[
new Image("graphics/star_bronze.png"),
new Image("graphics/star_silver.png"),
new Image("graphics/star_gold.png")
]
];
private var turnSpeed:Float;
private var currentSprite:Image;
private var sound:Sfx;
private var rand:Int;
private var randType:Int;
}

View file

@ -5,6 +5,7 @@ import com.haxepunk.utils.Input;
import com.haxepunk.HXP;
import com.haxepunk.utils.Touch;
import com.haxepunk.graphics.Text;
import com.haxepunk.Sfx;
import openfl.Assets;
import Bullet;
@ -15,6 +16,15 @@ class Player extends Entity {
public function new() {
super(HXP.halfWidth - 16, HXP.height - 200);
baseSprite = new Image("graphics/playerShip1_green.png");
shield = new Image("graphics/shield1.png");
shield.x -= 16;
shield.y -= 20;
#if flash
laser = new Sfx("audio/laser4.mp3");
#else
laser = new Sfx("audio/laser4.wav");
#end
graphic = baseSprite;
@ -78,7 +88,7 @@ class Player extends Entity {
}
private function onTouch(touch:Touch) {
if (touch.y < HXP.height - 100)
if (touch.y < HXP.height - 100 && (touch.y > 500) && this.y > 0)
this.moveTowards(touch.x - (this.width / 2), touch.y - (this.height * 2), moveSpeed * 1.5);
}
@ -87,9 +97,10 @@ class Player extends Entity {
this.scene.getClass(Score, score);
score[0].rem(5);
score[0].rem(500);
this.scene.add(new Bullet(this.x + this.width / 2, this.y));
laser.play();
}
public function die() {
@ -108,6 +119,10 @@ class Player extends Entity {
handleInput();
hitPause -= HXP.elapsed;
animWait -= HXP.elapsed;
shieldTimer -= HXP.elapsed;
if (shieldTimer < 0)
shielded = false;
if (animWait < 0) {
@ -126,11 +141,28 @@ class Player extends Entity {
this.addGraphic(fireEffectLeft);
this.addGraphic(fireEffectRight);
if (shielded)
this.addGraphic(shield);
currentAnim++;
animWait = .75;
}
if (collide("asteroid", this.x, this.y) != null && hitPause < 0) {
if ((hitPause > 0 && hitPause < .3) || (hitPause > .6 && hitPause < .9) || (hitPause > 1.2 && hitPause < 1.5)) {
this.visible = false;
}
else {
this.visible = true;
}
if (collide("asteroid", this.x, this.y) != null && hitPause < 0 && !shielded) {
var lives:Array<Lives> = [];
this.scene.getClass(Lives, lives);
lives[0].addDamage();
hitPause = 1.5;
}
if (collide("enemybullet", this.x, this.y) != null && hitPause < 0 && !shielded) {
var lives:Array<Lives> = [];
this.scene.getClass(Lives, lives);
lives[0].addDamage();
@ -141,6 +173,8 @@ class Player extends Entity {
}
private var baseSprite:Image;
private var shield:Image;
private var laser:Sfx;
private var fireEffectsLeft:Array<Image> = [];
private var fireEffectsRight:Array<Image> = [];
@ -149,8 +183,11 @@ class Player extends Entity {
private var fireEffectRight:Image;
private var moveSpeed:Int = 7;
private var hitPause:Float = 1.5;
private var hitPause:Float = 0;
private var animWait:Float = .75;
private var currentAnim:Int = 0;
public var shielded:Bool = false;
public var shieldTimer:Float = 1;
}

View file

@ -2,36 +2,42 @@ import com.haxepunk.Entity;
import com.haxepunk.HXP;
import com.haxepunk.graphics.Text;
import openfl.Assets;
class Score extends Entity {
public function new() {
super(0, 100);
super(HXP.width, 30);
super(HXP.halfWidth, 30);
name = "score";
score = 0;
scoreText = new Text("0", 0, 0, {size : 50});
score = 1000;
scoreText = new Text("$1000", 0, 0, 0, 0, {size : 50, align : "center", color : 0xFFF000});
scoreText.font = Assets.getFont("font/kenpixel_mini_square.ttf").fontName;
layer = -3;
this.addGraphic(scoreText);
}
public function add(x:Int) {
score += x;
scoreText.text = score + "";
scoreText.text = "$" + score;
}
public function rem(x:Int) {
if (score != 0) {
score -= x;
scoreText.text = score + "";
scoreText.text = "$" + score;
}
if (score < 0) {
score = 0;
scoreText.text = "$" + score;
}
}
public override function update() {
scoreText.originX = this.originX = 100;
scoreText.centerOrigin();
this.centerOrigin();
super.update();
}

View file

@ -13,6 +13,7 @@ class Spawner extends Entity {
spawnStarTime -= HXP.elapsed;
spawnAsteroidTime -= HXP.elapsed;
spawnEnemyTime -= HXP.elapsed;
spawnPickupTime -= HXP.elapsed;
if (spawnAsteroidTime < 0) {
this.scene.add(new Asteroid(HXP.width * Math.random(), -16));
@ -35,10 +36,16 @@ class Spawner extends Entity {
spawnEnemyTime = 5;
}
if (spawnPickupTime < 0) {
this.scene.add(new Pickup(HXP.width * Math.random(), -50));
spawnPickupTime = 5 * Math.random() + 5;
}
super.update();
}
private var spawnAsteroidTime:Float = .5;
private var spawnStarTime:Float = .5;
private var spawnEnemyTime:Float = 5;
private var spawnPickupTime:Float = 10;
}

View file

@ -9,11 +9,14 @@ class Title extends Entity {
public function new () {
super(HXP.width / 2, (HXP.height / 2) - 400);
var icon = new Image("graphics/cursor.png");
icon.scale = 3.5;
icon.x += 220;
var icon = new Image("graphics/playerShip1_green.png");
icon.scale = 1;
icon.angle = 45;
var txt = new Text("Spaaace");
icon.x += 180;
icon.y -= 10;
var txt = new Text("Spáááce");
txt.size = 80;
txt.x -= 30;
txt.font = Assets.getFont("font/kenpixel_mini_square.ttf").fontName;