Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<haxelib name="flixel" />
<haxelib name="flixel-addons" />

<!--In case you want to use the ui package-->
<haxelib name="flixel-ui" />
<haxelib name="haxeui-core" />
<haxelib name="haxeui-flixel" />

<!-- _____________________________ First Party Libraries _____________________ -->

Expand Down
2 changes: 0 additions & 2 deletions assets/gfx/INFO.txt

This file was deleted.

File renamed without changes
37 changes: 10 additions & 27 deletions assets/xml/main_menu.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<data>
<sprite x="0" y="0" width="100%" height="100%" name="title_image" src="title_image.png"/>
<button x="center" name="play_button" label="Play" align="center">
<!-- anchor the button at the center of the screen, 'flush' with the center of the button -->
<anchor x="center" x-flush="center" />
<param type="string" value="play"/>
</button>

<button x="center" name="credits_button" label="Credits" align="center">
<!-- anchor the button at the center of the screen, 'flush' with the center of the button -->
<anchor x="center" x-flush="center" />
<param type="string" value="credits"/>
</button>

<button x="center" name="exit_button" label="Exit" align="center">
<!-- anchor the button at the center of the screen, 'flush' with the center of the button -->
<anchor x="center" x-flush="center" />
<param type="string" value="exit"/>
</button>

<align axis="vertical" spacing="2" resize="false">
<!-- May need to add space if we want more objects in this alignment -->
<bounds top="70%" bottom="90%"/>
<objects value="play_button,credits_button,exit_button"/>
</align>
</data>
<vbox id="vbox1" width="100%" height="100%" >
<box width="100%" height="75%" />
<box width="100%" height="25%" >
<vbox id="menuItems" width="100%" verticalAlign="center" >
<button id="playButton" text="Play" horizontalAlign="center" width="60px" />
<button id="creditsButton" text="Credits" horizontalAlign="center" width="60px" />
<button id="quitButton" text="Quit" horizontalAlign="center" width="60px" />
</vbox>
</box>
</vbox>
7 changes: 7 additions & 0 deletions assets/xml/return_to_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vbox id="vbox1" width="100%" height="100%" >
<box width="100%" height="100%" >
<vbox id="menuItems" width="100%" verticalAlign="bottom" >
<button id="mainMenuButton" text="Main Menu" horizontalAlign="right" width="80px" />
</vbox>
</box>
</vbox>
4 changes: 4 additions & 0 deletions haxelib.deps
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ flixel-addons 2.10.0
flixel-ui 2.3.3
openfl 9.1.0

# UI deps
haxeui-core 1.2.3
haxeui-flixel 1.2.3

# bitDecayGames deps
bitdecaybtree git https://github.com/bitDecayGames/BehaviorTree.git
bitlytics git https://github.com/bitDecayGames/Bitlytics.git
Expand Down
2 changes: 2 additions & 0 deletions source/entities/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import input.InputCalcuator;
import flixel.util.FlxColor;
import flixel.FlxSprite;

using extensions.FlxObjectExt;

class Player extends FlxSprite {
var speed:Float = 30;
var playerNum = 0;
Expand Down
10 changes: 10 additions & 0 deletions source/extensions/FlxObjectExt.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package extensions;

import flixel.math.FlxPoint;
import flixel.FlxObject;

/**
Expand All @@ -15,4 +16,13 @@ class FlxObjectExt {
static public function setPositionMidpoint(o:FlxObject, x:Float, y:Float) {
o.setPosition(x - o.width / 2, y - o.height / 2);
}

/**
* Sets the FlxObject position from the given point
*
* @param p The point for the new position
*/
static public function setPositionPoint(o:FlxObject, p:FlxPoint) {
o.setPosition(p.x, p.y);
}
}
10 changes: 6 additions & 4 deletions source/input/SimpleController.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import flixel.input.gamepad.FlxGamepadInputID;
* Lovingly adapted from https://github.com/01010111/flixel-template
*/
class SimpleController {

static var key_bindings:Array<Map<Button, Array<FlxKey>>> = [
// PLAYER ONE
[
Expand Down Expand Up @@ -56,7 +55,8 @@ class SimpleController {

static function pressed_pad(button:Button, player:Int):Bool {
var gamepads = FlxG.gamepads.getActiveGamepads();
if (gamepads.length < player || gamepads[player] == null) return false;
if (gamepads.length < player || gamepads[player] == null)
return false;
return gamepads[player].anyPressed(pad_bindings[button]);
}

Expand All @@ -70,7 +70,8 @@ class SimpleController {

static function just_pressed_pad(button:Button, player:Int):Bool {
var gamepads = FlxG.gamepads.getActiveGamepads();
if (gamepads.length < player || gamepads[player] == null) return false;
if (gamepads.length < player || gamepads[player] == null)
return false;
return gamepads[player].anyJustPressed(pad_bindings[button]);
}

Expand All @@ -84,7 +85,8 @@ class SimpleController {

static function just_released_pad(button:Button, player:Int):Bool {
var gamepads = FlxG.gamepads.getActiveGamepads();
if (gamepads.length < player || gamepads[player] == null) return false;
if (gamepads.length < player || gamepads[player] == null)
return false;
return gamepads[player].anyJustReleased(pad_bindings[button]);
}
}
Expand Down
16 changes: 8 additions & 8 deletions source/states/CreditsState.hx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package states;

import ui.ReturnToMain;
import haxe.ui.focus.FocusManager;
import flixel.FlxState;
import config.Configure;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.addons.ui.FlxUIState;
import flixel.text.FlxText;
import flixel.ui.FlxButton;
import flixel.util.FlxColor;
Expand All @@ -14,10 +16,10 @@ import misc.FlxTextFactory;

using extensions.FlxStateExt;

class CreditsState extends FlxUIState {
class CreditsState extends FlxState {
var _allCreditElements:Array<FlxSprite>;

var _btnMainMenu:FlxButton;
var menu:ReturnToMain;

var _txtCreditsTitle:FlxText;
var _txtThankYou:FlxText;
Expand All @@ -43,12 +45,10 @@ class CreditsState extends FlxUIState {
bgColor = backgroundColor;
camera.pixelPerfectRender = true;

// Button
menu = new ReturnToMain(clickMainMenu);
add(menu);

_btnMainMenu = UiHelpers.createMenuButton("Main Menu", clickMainMenu);
_btnMainMenu.setPosition(FlxG.width - _btnMainMenu.width, FlxG.height - _btnMainMenu.height);
_btnMainMenu.updateHitbox();
add(_btnMainMenu);
FocusManager.instance.focus = menu.mainMenuButton;

// Credits

Expand Down
17 changes: 9 additions & 8 deletions source/states/FailState.hx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package states;

import flixel.FlxG;
import flixel.addons.ui.FlxUIState;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.ui.FlxButton;
import flixel.util.FlxColor;
import haxe.ui.focus.FocusManager;
import haxefmod.flixel.FmodFlxUtilities;
import helpers.UiHelpers;
import misc.FlxTextFactory;
import ui.ReturnToMain;

using extensions.FlxStateExt;

class VictoryState extends FlxUIState {
var _btnDone:FlxButton;
class FailState extends FlxState {
var menu:ReturnToMain;

var _txtTitle:FlxText;

Expand All @@ -24,10 +25,10 @@ class VictoryState extends FlxUIState {

add(_txtTitle);

_btnDone = UiHelpers.CreateMenuButton("Main Menu", clickMainMenu);
_btnDone.setPosition(FlxG.width / 2 - _btnDone.width / 2, FlxG.height - _btnDone.height - 40);
_btnDone.updateHitbox();
add(_btnDone);
menu = new ReturnToMain(clickMainMenu);
add(menu);

FocusManager.instance.focus = menu.mainMenuButton;
}

override public function update(elapsed:Float):Void {
Expand Down
Loading