diff --git a/project.xml b/project.xml index 0a11423..5510952 100644 --- a/project.xml +++ b/project.xml @@ -4,8 +4,8 @@ - - + + diff --git a/src/Main.hx b/src/Main.hx index 7196635..78683fe 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -15,7 +15,8 @@ class Main extends Engine HXP.resize(360, 640); #end - HXP.scene = new MainScene(); + // HXP.scene = new MainScene(); + HXP.scene = new MenuScene(); } public static function main() { new Main(); } diff --git a/src/MenuButton.hx b/src/MenuButton.hx new file mode 100644 index 0000000..6c2507b --- /dev/null +++ b/src/MenuButton.hx @@ -0,0 +1,54 @@ +import com.haxepunk.Entity; +import com.haxepunk.graphics.Image; +import com.haxepunk.graphics.Text; +import com.haxepunk.HXP; +import com.haxepunk.utils.Input; +import com.haxepunk.utils.Touch; +import com.haxepunk.utils.Key; + +import MainScene; + + +class MenuButton extends Entity { + + public function new (x:Float, y:Float, txt:String) { + super(x, y); + + sprite = new Image("graphics/buttonGreen.png"); + sprite.scale = 2; + + setHitbox(sprite.width * 2, sprite.height * 2); + + text = new Text(txt); + text.color = 0x000000; + text.size = 40; + + text.centerOrigin(); + sprite.centerOrigin(); + this.centerOrigin(); + + this.addGraphic(sprite); + this.addGraphic(text); + + Input.define("enter", [Key.ENTER, Key.SPACE]); + } + + public override function update() { + Input.touchPoints(onTouch); + + if (Input.check("enter")) { + HXP.scene = new MainScene(); + } + } + + private function onTouch(touch:Touch) { + if ((touch.x > this.left && touch.x < this.right) && (touch.y > this.top && touch.y < this.bottom)) { + HXP.scene = new MainScene(); + } + } + + private var txt:String; + private var sprite:Image; + public var text:Text; + +} \ No newline at end of file diff --git a/src/MenuScene.hx b/src/MenuScene.hx new file mode 100644 index 0000000..ad06f2e --- /dev/null +++ b/src/MenuScene.hx @@ -0,0 +1,22 @@ +import com.haxepunk.Scene; +import com.haxepunk.HXP; +import com.haxepunk.graphics.Text; + +import MenuButton; +import Title; + +class MenuScene extends Scene { + + public override function begin() { + var play = new MenuButton(HXP.width / 2, HXP.height / 2, "Play!"); + var title = new Title(HXP.width / 2, (HXP.height / 2) - 400); + var copy = new Text("By Bram \"96AA48\" van der Veen, 2014", HXP.width / 2, HXP.height - 50); + + copy.size = 22; + copy.centerOrigin(); + + add(title); + add(play); + addGraphic(copy); + } +} \ No newline at end of file diff --git a/src/Player.hx b/src/Player.hx index 3aeed08..346d928 100644 --- a/src/Player.hx +++ b/src/Player.hx @@ -41,7 +41,7 @@ class Player extends Entity { this.y -= moveSpeed; } - if (Input.pressed("shoot")) { + if (Input.check("shoot")) { shoot(); } @@ -63,7 +63,7 @@ class Player extends Entity { var asteroid = collide("asteroid", this.x, this.y); if (asteroid != null) { - trace(asteroid); + } super.update(); diff --git a/src/Title.hx b/src/Title.hx new file mode 100644 index 0000000..05d7e5b --- /dev/null +++ b/src/Title.hx @@ -0,0 +1,26 @@ +import com.haxepunk.Entity; +import com.haxepunk.graphics.Image; +import com.haxepunk.graphics.Text; + +class Title extends Entity { + + public function new (x:Float, y:Float) { + super(x, y); + + var icon = new Image("graphics/cursor.png"); + icon.scale = 3.5; + icon.x += 200; + + var txt = new Text("Spaaace"); + txt.size = 80; + txt.x -= 20; + + this.centerOrigin(); + txt.centerOrigin(); + icon.centerOrigin(); + + this.addGraphic(txt); + this.addGraphic(icon); + } + +} \ No newline at end of file