Merge branch 'master' of hexlime.tk:games/space

Conflicts:
	src/Boss.hx
	src/Spawner.hx
This commit is contained in:
Bram van der Veen 2014-07-11 17:50:15 +02:00
commit 4f70dc21c6
47 changed files with 1290 additions and 1110 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -17,7 +17,7 @@ class Boss extends Entity {
currentSprite.scale = 8;
currentSprite.smooth = false;
maxEnemies = Math.floor(Math.random() * (color + 1) * 2);
maxEnemies = Math.floor((color + 1) * 2);
graphic = currentSprite;
@ -51,7 +51,9 @@ class Boss extends Entity {
var enemies:Array<Enemy> = [];
this.scene.getClass(Enemy, enemies);
if (spawnTimer < 0 && enemies.length != maxEnemies - 1 && canSpawn) {
trace(enemies.length + ", " + maxEnemies);
if (spawnTimer < 0 && enemies.length != maxEnemies && canSpawn) {
this.scene.add(new Enemy(this.width / 2, 20, color, Math.floor(Math.random() * 4) + 1));
spawnTimer = .75;
}
@ -115,5 +117,4 @@ class Boss extends Entity {
private var explosionTimer:Float = 0;
private var counter:Int = 0;
private var dead:Bool = false;
}

View file

@ -7,12 +7,12 @@ class Bullet extends Entity {
public function new(x:Float, y:Float) {
super(x, y);
laser1 = new Image("graphics/laserGreen09.png");
laser2 = new Image("graphics/laserGreen13.png");
laser1 = new Image("graphics/laserGreen04.png");
laser2 = new Image("graphics/laserGreen12.png");
graphic = laser1;
setHitbox(9, 37);
setHitboxTo(laser1);
type = "bullet";

View file

@ -15,8 +15,7 @@ class Main extends Engine
HXP.resize(360, 640);
#end
// HXP.scene = new MainScene();
HXP.scene = new MenuScene();
HXP.scene = new StoreScene();
}
public static function main() { new Main(); }

View file

@ -45,10 +45,12 @@ class MenuButton extends Entity {
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;
Assets.cache.clear();
HXP.scene = new MainScene();
}
else {
HXP.scene = null;
Assets.cache.clear();
HXP.scene = new MenuScene();
}
}
@ -57,10 +59,12 @@ class MenuButton extends Entity {
if (Input.check("enter")) {
if (this.text.text != "Menu") {
HXP.scene = null;
Assets.cache.clear();
HXP.scene = new MainScene();
}
else {
HXP.scene = null;
Assets.cache.clear();
HXP.scene = new MenuScene();
}
}
@ -70,10 +74,12 @@ class MenuButton extends Entity {
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;
Assets.cache.clear();
HXP.scene = new MainScene();
}
else {
HXP.scene = null;
Assets.cache.clear();
HXP.scene = new MenuScene();
}
}

View file

@ -81,7 +81,7 @@ class Player extends Entity {
this.y -= moveSpeed;
}
if (Input.check("shoot")) {
if (Input.pressed("shoot")) {
shoot();
}

View file

@ -3,12 +3,14 @@ import com.haxepunk.HXP;
import Enemy;
import Boss;
import Star;
import Pickup;
import Asteroid;
class Spawner extends Entity {
public function new() {
super(0,0);
}
public override function update() {
@ -49,6 +51,26 @@ class Spawner extends Entity {
else {
trace("YOU BEAT THE GAME!");
}
spawnStarTime -= HXP.elapsed;
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;
}
}
private var level:Int = 0;
@ -58,4 +80,8 @@ class Spawner extends Entity {
private var enemyType:Int = 1;
public var bossSpawned:Bool = false;
private var spawnPickupTime:Float = 10;
private var spawnAsteroidTime:Float = .5;
private var spawnStarTime:Float = .5;
}

124
src/StoreItem.hx Normal file
View file

@ -0,0 +1,124 @@
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.graphics.Text;
import openfl.Assets;
class StoreItem extends Entity {
public function new(x:Float, y:Float, type:Int) {
super(x, y);
button = new Image("graphics/buttonGreen.png");
button.scale = 2;
text = new Text(itemnames[type]);
text.color = 0x000000;
text.size = 40;
text.font = Assets.getFont("font/kenpixel_mini_square.ttf").fontName;
this.x += 120;
setHitbox(button.width * 2, button.height * 2);
text.centerOrigin();
button.centerOrigin();
this.centerOrigin();
for (i in 0...items[type].length) {
sprites[i] = new Image("graphics/" + items[type][i]);
sprites[i].x = -350;
sprites[i].centerOrigin();
}
arrowLeft = new Image("graphics/fire05.png");
arrowLeft.angle = 90;
arrowLeft.x = -440;
arrowLeft.centerOrigin();
arrowRight = new Image("graphics/fire05.png");
arrowRight.angle = -90;
arrowRight.x = -260;
arrowRight.centerOrigin();
this.addGraphic(sprites[0]);
this.addGraphic(arrowLeft);
this.addGraphic(arrowRight);
this.addGraphic(button);
this.addGraphic(text);
}
private var button:Image;
private var sprites:Array<Image> = [];
private var arrowLeft:Image;
private var arrowRight:Image;
private var text:Text;
public static var itemnames:Array<String> = [
"Fat Jumper",
"Speeder Jumper",
"X3 Jumper",
"V2 Laser",
"Heavy Laser"
];
private var items:Array<Array<String>> = [
[
"playerShip3_green.png",
"playerShip3_blue.png",
"playerShip3_orange.png"
],
[
"playerShip1_green.png",
"playerShip1_blue.png",
"playerShip1_orange.png"
],
[
"playerShip2_green.png",
"playerShip2_blue.png",
"playerShip2_orange.png"
],
[
"laserGreen06.png",
"laserBlue06.png"
],
[
"laserBlue16.png"
]
];
private var prices:Array<Array<Int>> = [
[
50000,
50000,
50000
],
[
100000,
100000,
100000
],
[
150000,
150000,
150000
],
[
50000,
100000
],
[
150000
]
];
}

24
src/StoreScene.hx Normal file
View file

@ -0,0 +1,24 @@
import com.haxepunk.Scene;
import com.haxepunk.graphics.Backdrop;
import com.haxepunk.HXP;
import StoreItem;
class StoreScene extends Scene {
public override function begin() {
backdrop = new Backdrop("graphics/darkPurple.png", true, true);
addGraphic(backdrop);
for (i in 0...StoreItem.itemnames.length) {
add(new StoreItem(HXP.halfWidth, 200 + (i * 200), i));
}
}
public override function update() {
super.update();
backdrop.y += 1;
}
private var backdrop:Backdrop;
}