Merge branch 'master' of hexlime.tk:games/space
Conflicts: src/Boss.hx src/Spawner.hx
BIN
assets/graphics/laserBlue01.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
assets/graphics/laserBlue02.png
Normal file
After Width: | Height: | Size: 318 B |
BIN
assets/graphics/laserBlue03.png
Normal file
After Width: | Height: | Size: 274 B |
BIN
assets/graphics/laserBlue04.png
Normal file
After Width: | Height: | Size: 322 B |
BIN
assets/graphics/laserBlue05.png
Normal file
After Width: | Height: | Size: 276 B |
BIN
assets/graphics/laserBlue06.png
Normal file
After Width: | Height: | Size: 691 B |
BIN
assets/graphics/laserBlue07.png
Normal file
After Width: | Height: | Size: 617 B |
BIN
assets/graphics/laserBlue08.png
Normal file
After Width: | Height: | Size: 882 B |
BIN
assets/graphics/laserBlue09.png
Normal file
After Width: | Height: | Size: 754 B |
BIN
assets/graphics/laserBlue10.png
Normal file
After Width: | Height: | Size: 771 B |
BIN
assets/graphics/laserBlue11.png
Normal file
After Width: | Height: | Size: 719 B |
BIN
assets/graphics/laserBlue12.png
Normal file
After Width: | Height: | Size: 321 B |
BIN
assets/graphics/laserBlue13.png
Normal file
After Width: | Height: | Size: 281 B |
BIN
assets/graphics/laserBlue14.png
Normal file
After Width: | Height: | Size: 332 B |
BIN
assets/graphics/laserBlue15.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
assets/graphics/laserBlue16.png
Normal file
After Width: | Height: | Size: 802 B |
BIN
assets/graphics/playerShip1_blue.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/graphics/playerShip1_orange.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/graphics/playerShip1_red.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/graphics/playerShip2_blue.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/graphics/playerShip2_green.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/graphics/playerShip2_orange.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
assets/graphics/playerShip2_red.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/graphics/playerShip3_blue.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/graphics/playerShip3_green.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/graphics/playerShip3_orange.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
assets/graphics/playerShip3_red.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
|
@ -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;
|
||||
|
||||
}
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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(); }
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class Player extends Entity {
|
|||
this.y -= moveSpeed;
|
||||
}
|
||||
|
||||
if (Input.check("shoot")) {
|
||||
if (Input.pressed("shoot")) {
|
||||
shoot();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
@ -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
|
@ -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;
|
||||
}
|