diff --git a/Project.xml b/Project.xml
index d0695e1..d3561ed 100644
--- a/Project.xml
+++ b/Project.xml
@@ -22,7 +22,7 @@
-
+
@@ -90,4 +90,4 @@
-
+
\ No newline at end of file
diff --git a/assets/images/background.png b/assets/images/background.png
deleted file mode 100644
index bb077b3..0000000
Binary files a/assets/images/background.png and /dev/null differ
diff --git a/assets/images/ground.png b/assets/images/ground.png
deleted file mode 100644
index 27ad982..0000000
Binary files a/assets/images/ground.png and /dev/null differ
diff --git a/assets/images/mobilebg.png b/assets/images/mobilebg.png
new file mode 100644
index 0000000..ac7997b
Binary files /dev/null and b/assets/images/mobilebg.png differ
diff --git a/source/GameOverState.hx b/source/GameOverState.hx
index bb4c7c2..b95a965 100644
--- a/source/GameOverState.hx
+++ b/source/GameOverState.hx
@@ -4,6 +4,7 @@ import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.text.FlxText;
+import openfl.system.System;
class GameOverState extends FlxState
{
@@ -37,6 +38,13 @@ class GameOverState extends FlxState
var enterText:FlxText = new FlxText(0, FlxG.height / 2 + 150, FlxG.width, "Press Enter or Tap to Play Again");
enterText.setFormat(AssetPaths.prstart__ttf, 20, 0xffffffff, "center");
add(enterText);
+
+ // press x to exit
+ #if desktop
+ var exitText:FlxText = new FlxText(0, FlxG.height - 50, FlxG.width, "Press X to Exit");
+ exitText.setFormat(AssetPaths.prstart__ttf, 20, 0xffffffff, "center");
+ add(exitText);
+ #end
}
override public function update(elapsed)
@@ -58,5 +66,10 @@ class GameOverState extends FlxState
PlayState.score = 0;
FlxG.switchState(new PlayState());
}
+
+ #if desktop
+ if (FlxG.keys.anyJustPressed([X, ESCAPE]))
+ System.exit(0);
+ #end
}
}
diff --git a/source/Main.hx b/source/Main.hx
index 4890464..4dd517f 100644
--- a/source/Main.hx
+++ b/source/Main.hx
@@ -8,6 +8,7 @@ class Main extends Sprite
public function new()
{
super();
+
addChild(new FlxGame(0, 0, MainMenuState));
}
}
diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx
index 52cd383..66a9439 100644
--- a/source/MainMenuState.hx
+++ b/source/MainMenuState.hx
@@ -4,6 +4,7 @@ import flixel.FlxG;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.ui.FlxButton;
+import openfl.system.System;
class MainMenuState extends FlxState
{
@@ -25,6 +26,10 @@ class MainMenuState extends FlxState
creditsText.setFormat(AssetPaths.prstart__ttf, 8, 0xFFFFFFFF, "center");
add(creditsText);
+ // exit game button
+ var exitButton:FlxButton = new FlxButton(FlxG.width - 50, 0, "X", exitGame);
+ add(exitButton);
+
// settings button
/*var settingsButton:FlxButton = new FlxButton(FlxG.width / 2 - 50, FlxG.height / 2 + 100, "Settings", settingsButt);
add(settingsButton); */
@@ -46,4 +51,9 @@ class MainMenuState extends FlxState
FlxG.switchState(new SettingsState());
#end
}
+
+ function exitGame()
+ {
+ System.exit(0);
+ }
}
diff --git a/source/PlayState.hx b/source/PlayState.hx
index 1df7d9d..653ac58 100644
--- a/source/PlayState.hx
+++ b/source/PlayState.hx
@@ -11,7 +11,6 @@ class PlayState extends FlxState
{
var player:Player;
- var ground:FlxSprite;
var pipeTop:FlxSprite;
var pipeBottom:FlxSprite;
var pipePieceBottom:FlxSprite;
@@ -35,29 +34,21 @@ class PlayState extends FlxState
{
super.create();
- // create background
var backgroundCol:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, 0xFF96FFFF);
add(backgroundCol);
- var background:FlxSprite = new FlxSprite(0, 0, AssetPaths.background__png);
- background.setGraphicSize(FlxG.width);
+ var background:FlxSprite = new FlxSprite(0, 0, AssetPaths.mobilebg__png);
+ background.setGraphicSize(FlxG.width, FlxG.height);
background.updateHitbox();
- background.setPosition(0, FlxG.height - background.height);
add(background);
- ground = new FlxSprite(0, 0, AssetPaths.ground__png);
- ground.setGraphicSize(FlxG.width);
- ground.updateHitbox();
- ground.y = FlxG.height - ground.height;
- add(ground);
-
scoreUI = new FlxText(0, 0, FlxG.width, "0");
scoreUI.setFormat(AssetPaths.prstart__ttf, 64, 0xFFFFFFFF, "center");
scoreUI.y = FlxG.height - scoreUI.height;
uiTextGroup.add(scoreUI);
add(scoreUI);
- player = new Player(24, FlxG.height * 0.5);
+ player = new Player(FlxG.width * 0.5, FlxG.height * 0.5);
add(player);
createPipe();
@@ -71,7 +62,7 @@ class PlayState extends FlxState
scoreUI.text = "" + score;
- if (player.y <= 0 || player.y >= FlxG.height - (ground.height * 0.5))
+ if (player.y <= 0 || player.y >= FlxG.height - 124)
{
FlxG.switchState(new GameOverState());
}