Initial Commit
* Adds Menu * Adds Level Manager - LevelBase * Adds Sample level * Basic player movement
This commit is contained in:
46
.gitignore
vendored
Normal file
46
.gitignore
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Build Folders
|
||||||
|
export/
|
||||||
6
.vscode/extensions.json
vendored
Normal file
6
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"openfl.lime-vscode-extension",
|
||||||
|
"redhat.vscode-xml"
|
||||||
|
]
|
||||||
|
}
|
||||||
21
.vscode/launch.json
vendored
Normal file
21
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Build + Debug",
|
||||||
|
"type": "lime",
|
||||||
|
"request": "launch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"type": "lime",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Macro",
|
||||||
|
"type": "haxe-eval",
|
||||||
|
"request": "launch"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
13
.vscode/settings.json
vendored
Normal file
13
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"search.exclude": {
|
||||||
|
"export/**/*.hx": true
|
||||||
|
},
|
||||||
|
"[haxe]": {
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.formatOnPaste": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.sortImports": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"haxe.enableExtendedIndentation": true
|
||||||
|
}
|
||||||
13
.vscode/tasks.json
vendored
Normal file
13
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "lime",
|
||||||
|
"command": "test",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
85
Project.xml
Normal file
85
Project.xml
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project xmlns="http://lime.software/project/1.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://lime.software/project/1.0.2 http://lime.software/xsd/project-1.0.2.xsd">
|
||||||
|
|
||||||
|
<!-- _________________________ Application Settings _________________________ -->
|
||||||
|
|
||||||
|
<app title="RAW-HAXE" file="RAW-HAXE" main="Main" version="0.0.1" company="HaxeFlixel" />
|
||||||
|
|
||||||
|
<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
|
||||||
|
or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
|
||||||
|
<app preloader="flixel.system.FlxPreloader" />
|
||||||
|
|
||||||
|
<!--Minimum without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2-->
|
||||||
|
<set name="SWF_VERSION" value="11.8" />
|
||||||
|
|
||||||
|
<!-- ____________________________ Window Settings ___________________________ -->
|
||||||
|
|
||||||
|
<!--These window settings apply to all targets-->
|
||||||
|
<window width="640" height="480" fps="60" background="#000000" hardware="true" vsync="false" />
|
||||||
|
|
||||||
|
<!--HTML5-specific-->
|
||||||
|
<window if="html5" resizable="false" />
|
||||||
|
|
||||||
|
<!--Desktop-specific-->
|
||||||
|
<window if="desktop" orientation="landscape" fullscreen="false" resizable="true" />
|
||||||
|
|
||||||
|
<!--Mobile-specific-->
|
||||||
|
<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />
|
||||||
|
|
||||||
|
<!-- _____________________________ Path Settings ____________________________ -->
|
||||||
|
|
||||||
|
<set name="BUILD_DIR" value="export" />
|
||||||
|
<source path="source" />
|
||||||
|
<assets path="assets" />
|
||||||
|
|
||||||
|
<!-- _______________________________ Libraries ______________________________ -->
|
||||||
|
|
||||||
|
<haxelib name="flixel" />
|
||||||
|
<haxelib name="djFlixel"/>
|
||||||
|
|
||||||
|
<!--In case you want to use the addons package-->
|
||||||
|
<haxelib name="flixel-addons" />
|
||||||
|
|
||||||
|
<!--In case you want to use the ui package-->
|
||||||
|
<!-- <haxelib name="flixel-ui" /> -->
|
||||||
|
|
||||||
|
<!--In case you want to use nape with flixel-->
|
||||||
|
<!--<haxelib name="nape-haxe4" />-->
|
||||||
|
|
||||||
|
<!-- ______________________________ Haxedefines _____________________________ -->
|
||||||
|
|
||||||
|
<!--Enable the Flixel core recording system-->
|
||||||
|
<!--<haxedef name="FLX_RECORD" />-->
|
||||||
|
|
||||||
|
<!--Disable the right and middle mouse buttons-->
|
||||||
|
<!--<haxedef name="FLX_NO_MOUSE_ADVANCED" />-->
|
||||||
|
|
||||||
|
<!--Disable the native cursor API on Flash-->
|
||||||
|
<!--<haxedef name="FLX_NO_NATIVE_CURSOR" />-->
|
||||||
|
|
||||||
|
<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
|
||||||
|
<haxedef name="FLX_NO_MOUSE" if="mobile" />
|
||||||
|
<haxedef name="FLX_NO_KEYBOARD" if="mobile" />
|
||||||
|
<haxedef name="FLX_NO_TOUCH" if="desktop" />
|
||||||
|
<!--<haxedef name="FLX_NO_GAMEPAD" />-->
|
||||||
|
|
||||||
|
<!--Disable the Flixel core sound tray-->
|
||||||
|
<!--<haxedef name="FLX_NO_SOUND_TRAY" />-->
|
||||||
|
|
||||||
|
<!--Disable the Flixel sound management code-->
|
||||||
|
<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->
|
||||||
|
|
||||||
|
<!--Disable the Flixel core focus lost screen-->
|
||||||
|
<!--<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />-->
|
||||||
|
|
||||||
|
<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
|
||||||
|
<haxedef name="FLX_NO_DEBUG" unless="debug" />
|
||||||
|
|
||||||
|
<!--Enable this for Nape release builds for a serious peformance improvement-->
|
||||||
|
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />
|
||||||
|
|
||||||
|
<!-- _________________________________ Custom _______________________________ -->
|
||||||
|
|
||||||
|
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
|
||||||
|
</project>
|
||||||
BIN
assets/data/MrPixel.otf
Normal file
BIN
assets/data/MrPixel.otf
Normal file
Binary file not shown.
50
assets/data/level1.json
Normal file
50
assets/data/level1.json
Normal file
File diff suppressed because one or more lines are too long
89
assets/data/maps.ogmo
Normal file
89
assets/data/maps.ogmo
Normal file
File diff suppressed because one or more lines are too long
BIN
assets/images/bg.png
Normal file
BIN
assets/images/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
assets/images/sci-fi-tileset.png
Normal file
BIN
assets/images/sci-fi-tileset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
0
assets/music/music-goes-here.txt
Normal file
0
assets/music/music-goes-here.txt
Normal file
0
assets/sounds/sounds-go-here.txt
Normal file
0
assets/sounds/sounds-go-here.txt
Normal file
15
hxformat.json
Normal file
15
hxformat.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"lineEnds": {
|
||||||
|
"leftCurly": "both",
|
||||||
|
"rightCurly": "both",
|
||||||
|
"objectLiteralCurly": {
|
||||||
|
"leftCurly": "after"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sameLine": {
|
||||||
|
"ifElse": "next",
|
||||||
|
"doWhile": "next",
|
||||||
|
"tryBody": "next",
|
||||||
|
"tryCatch": "next"
|
||||||
|
}
|
||||||
|
}
|
||||||
4
source/AssetPaths.hx
Normal file
4
source/AssetPaths.hx
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package;
|
||||||
|
|
||||||
|
@:build(flixel.system.FlxAssets.buildFileReferences("assets", true))
|
||||||
|
class AssetPaths {}
|
||||||
19
source/Main.hx
Normal file
19
source/Main.hx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package;
|
||||||
|
|
||||||
|
import djFlixel.D;
|
||||||
|
import flixel.FlxGame;
|
||||||
|
import openfl.display.Sprite;
|
||||||
|
|
||||||
|
class Main extends Sprite
|
||||||
|
{
|
||||||
|
public function new()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
D.init({
|
||||||
|
name: "RAW" + D.DJFLX_VER,
|
||||||
|
debug_keys: true, // Automatic asset reload on [F12]
|
||||||
|
smoothing: false,
|
||||||
|
});
|
||||||
|
addChild(new FlxGame(0, 0, PlayState, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
19
source/PlayState.hx
Normal file
19
source/PlayState.hx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxState;
|
||||||
|
import scenes.MenuState;
|
||||||
|
|
||||||
|
class PlayState extends FlxState
|
||||||
|
{
|
||||||
|
override public function create()
|
||||||
|
{
|
||||||
|
super.create();
|
||||||
|
FlxG.switchState(new MenuState());
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function update(elapsed:Float)
|
||||||
|
{
|
||||||
|
super.update(elapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
56
source/core/LevelBase.hx
Normal file
56
source/core/LevelBase.hx
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package core;
|
||||||
|
|
||||||
|
import core.Types.LevelConfig;
|
||||||
|
import entities.Player;
|
||||||
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxState;
|
||||||
|
import flixel.addons.editors.ogmo.FlxOgmo3Loader;
|
||||||
|
import flixel.tile.FlxTilemap;
|
||||||
|
import scenes.GameOver;
|
||||||
|
|
||||||
|
class LevelBase extends FlxState
|
||||||
|
{
|
||||||
|
var map:FlxOgmo3Loader;
|
||||||
|
var bg:FlxTilemap;
|
||||||
|
var walls:FlxTilemap;
|
||||||
|
var _player:Player;
|
||||||
|
|
||||||
|
public function new(levelConfig:LevelConfig)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
map = new FlxOgmo3Loader(levelConfig.ogmoLevel, levelConfig.levelJson);
|
||||||
|
bg = map.loadTilemap(levelConfig.bgTileSheet, "bg");
|
||||||
|
walls = map.loadTilemap(levelConfig.wallTilesheet, "walls");
|
||||||
|
bg.scrollFactor.set(.33, .33);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function create()
|
||||||
|
{
|
||||||
|
super.create();
|
||||||
|
add(bg);
|
||||||
|
add(walls);
|
||||||
|
map.loadEntities(loadPlayer, 'player_layer');
|
||||||
|
FlxG.camera.setScrollBoundsRect(0, 0, walls.width, walls.height, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function update(elapsed:Float)
|
||||||
|
{
|
||||||
|
super.update(elapsed);
|
||||||
|
FlxG.collide(_player, walls);
|
||||||
|
|
||||||
|
if (_player.y > walls.height)
|
||||||
|
{
|
||||||
|
openSubState(new GameOver());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPlayer(entity:EntityData)
|
||||||
|
{
|
||||||
|
if (entity.name == "player")
|
||||||
|
{
|
||||||
|
_player = new Player(entity.x, entity.y);
|
||||||
|
add(_player);
|
||||||
|
FlxG.camera.follow(_player, NO_DEAD_ZONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
source/core/Types.hx
Normal file
9
source/core/Types.hx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package core;
|
||||||
|
|
||||||
|
typedef LevelConfig =
|
||||||
|
{
|
||||||
|
var ogmoLevel:String;
|
||||||
|
var levelJson:String;
|
||||||
|
var wallTilesheet:String;
|
||||||
|
var bgTileSheet:String;
|
||||||
|
}
|
||||||
75
source/entities/Player.hx
Normal file
75
source/entities/Player.hx
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package entities;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxSprite;
|
||||||
|
import flixel.input.actions.FlxAction.FlxActionDigital;
|
||||||
|
import flixel.input.actions.FlxActionManager;
|
||||||
|
import flixel.util.FlxColor;
|
||||||
|
|
||||||
|
class Player extends FlxSprite
|
||||||
|
{
|
||||||
|
var actionsManager:FlxActionManager;
|
||||||
|
|
||||||
|
var _left:FlxActionDigital;
|
||||||
|
var _right:FlxActionDigital;
|
||||||
|
var _jump:FlxActionDigital;
|
||||||
|
var _jumpPower:Int = 200;
|
||||||
|
|
||||||
|
public function new(x:Int, y:Int)
|
||||||
|
{
|
||||||
|
super(x, y);
|
||||||
|
|
||||||
|
makeGraphic(16, 16, FlxColor.BLUE);
|
||||||
|
var runSpeed:Int = 80;
|
||||||
|
drag.x = runSpeed * 8;
|
||||||
|
acceleration.y = 420;
|
||||||
|
maxVelocity.set(runSpeed, _jumpPower);
|
||||||
|
|
||||||
|
_left = new FlxActionDigital().addKey(LEFT, PRESSED);
|
||||||
|
_right = new FlxActionDigital().addKey(RIGHT, PRESSED);
|
||||||
|
_jump = new FlxActionDigital().addKey(X, JUST_PRESSED);
|
||||||
|
|
||||||
|
if (actionsManager == null)
|
||||||
|
{
|
||||||
|
actionsManager = FlxG.inputs.add(new FlxActionManager());
|
||||||
|
}
|
||||||
|
actionsManager.addActions([_left, _right, _jump]);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function update(elapsed:Float):Void
|
||||||
|
{
|
||||||
|
acceleration.x = 0;
|
||||||
|
updateInputs();
|
||||||
|
super.update(elapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateInputs()
|
||||||
|
{
|
||||||
|
if (_left.triggered)
|
||||||
|
moveLeft();
|
||||||
|
else if (_right.triggered)
|
||||||
|
moveRight();
|
||||||
|
if (_jump.triggered)
|
||||||
|
jump();
|
||||||
|
// if (_shoot.triggered)
|
||||||
|
// shoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveLeft()
|
||||||
|
{
|
||||||
|
acceleration.x -= drag.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveRight()
|
||||||
|
{
|
||||||
|
acceleration.x += drag.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function jump()
|
||||||
|
{
|
||||||
|
if (velocity.y == 0)
|
||||||
|
{
|
||||||
|
velocity.y = -_jumpPower;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
source/scenes/Credits.hx
Normal file
16
source/scenes/Credits.hx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package scenes;
|
||||||
|
|
||||||
|
import flixel.FlxState;
|
||||||
|
|
||||||
|
class Credits extends FlxState
|
||||||
|
{
|
||||||
|
override public function create()
|
||||||
|
{
|
||||||
|
super.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function update(elapsed:Float)
|
||||||
|
{
|
||||||
|
super.update(elapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
73
source/scenes/GameOver.hx
Normal file
73
source/scenes/GameOver.hx
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package scenes;
|
||||||
|
|
||||||
|
import djFlixel.gfx.pal.Pal_DB32;
|
||||||
|
import djFlixel.ui.FlxMenu;
|
||||||
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxSprite;
|
||||||
|
import flixel.FlxSubState;
|
||||||
|
import flixel.math.FlxPoint;
|
||||||
|
import flixel.util.FlxColor;
|
||||||
|
import flixel.util.FlxSpriteUtil;
|
||||||
|
|
||||||
|
class GameOver extends FlxSubState
|
||||||
|
{
|
||||||
|
var bgWidth:Int = 126;
|
||||||
|
var bgHeight:Int = 116;
|
||||||
|
var menuWidth:Int = 90;
|
||||||
|
var bgMenuSpace:Int = 16;
|
||||||
|
var bgRectDiff:Int = 2;
|
||||||
|
var menuFontSize:Int = 20;
|
||||||
|
|
||||||
|
public function new()
|
||||||
|
{
|
||||||
|
super(0x33000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function create()
|
||||||
|
{
|
||||||
|
super.create();
|
||||||
|
|
||||||
|
var bg:FlxSprite = new FlxSprite();
|
||||||
|
bg.makeGraphic(menuWidth + (bgMenuSpace * 2) + (bgRectDiff * 2), bgHeight, FlxColor.TRANSPARENT);
|
||||||
|
|
||||||
|
FlxSpriteUtil.drawRoundRect(bg, 0, 0, (bgWidth - (bgRectDiff * 2)), bgHeight, 10, 10, FlxColor.BLACK);
|
||||||
|
var _menu = new FlxMenu(FlxG.width / 2 - (menuWidth / 2 - menuFontSize), FlxG.height / 2, menuWidth);
|
||||||
|
|
||||||
|
bg.setPosition((_menu.x - bgMenuSpace), (_menu.y) - (bgMenuSpace * 2));
|
||||||
|
_menu.stI.text = {
|
||||||
|
f: AssetPaths.MrPixel__otf,
|
||||||
|
s: menuFontSize,
|
||||||
|
bt: 1,
|
||||||
|
so: [1, 1]
|
||||||
|
};
|
||||||
|
_menu.PARAMS.enable_mouse = false;
|
||||||
|
_menu.stI.col_t = {
|
||||||
|
idle: Pal_DB32.COL[21],
|
||||||
|
focus: Pal_DB32.COL[28],
|
||||||
|
accent: Pal_DB32.COL[29],
|
||||||
|
dis: Pal_DB32.COL[25], // Disabled
|
||||||
|
dis_f: Pal_DB32.COL[23], // Disabled focused
|
||||||
|
};
|
||||||
|
_menu.stI.col_b = {
|
||||||
|
idle: Pal_DB32.COL[1],
|
||||||
|
focus: Pal_DB32.COL[0]
|
||||||
|
};
|
||||||
|
_menu.stHeader = {
|
||||||
|
f: AssetPaths.MrPixel__otf,
|
||||||
|
s: 16,
|
||||||
|
bt: 2,
|
||||||
|
bs: 1,
|
||||||
|
c: Pal_DB32.COL[8],
|
||||||
|
bc: Pal_DB32.COL[27]
|
||||||
|
};
|
||||||
|
_menu.PARAMS.header_CPS = 30;
|
||||||
|
_menu.PARAMS.page_anim_parallel = true;
|
||||||
|
_menu.createPage('main', "GAME OVER").addM(['Restart |link|restart', 'Home |link|home', 'Exit |link|exit']);
|
||||||
|
_menu.onItemEvent = (a, b) -> {};
|
||||||
|
add(bg);
|
||||||
|
add(_menu);
|
||||||
|
_menu.goto('main');
|
||||||
|
FlxG.camera.follow(null);
|
||||||
|
FlxG.camera.focusOn(new FlxPoint(0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
27
source/scenes/Level1.hx
Normal file
27
source/scenes/Level1.hx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package scenes;
|
||||||
|
|
||||||
|
import core.LevelBase;
|
||||||
|
import flixel.FlxState;
|
||||||
|
|
||||||
|
class Level1 extends LevelBase
|
||||||
|
{
|
||||||
|
public function new()
|
||||||
|
{
|
||||||
|
super({
|
||||||
|
ogmoLevel: AssetPaths.maps__ogmo,
|
||||||
|
bgTileSheet: AssetPaths.bg__png,
|
||||||
|
wallTilesheet: AssetPaths.sci_fi_tileset__png,
|
||||||
|
levelJson: AssetPaths.level1__json
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function create()
|
||||||
|
{
|
||||||
|
super.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function update(elapsed:Float)
|
||||||
|
{
|
||||||
|
super.update(elapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
81
source/scenes/MenuState.hx
Normal file
81
source/scenes/MenuState.hx
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package scenes;
|
||||||
|
|
||||||
|
import djFlixel.gfx.StarfieldSimple;
|
||||||
|
import djFlixel.gfx.pal.Pal_DB32;
|
||||||
|
import djFlixel.ui.FlxMenu;
|
||||||
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxState;
|
||||||
|
import openfl.system.System;
|
||||||
|
|
||||||
|
class MenuState extends FlxState
|
||||||
|
{
|
||||||
|
override public function create()
|
||||||
|
{
|
||||||
|
super.create();
|
||||||
|
this.generateStarField();
|
||||||
|
this.createMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generateStarField()
|
||||||
|
{
|
||||||
|
var stars = new StarfieldSimple();
|
||||||
|
stars.WIDE_PIXEL = false;
|
||||||
|
stars.STAR_SPEED = 1.9;
|
||||||
|
add(stars);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createMenu()
|
||||||
|
{
|
||||||
|
var _menu = new FlxMenu(FlxG.width / 2 - (70 - 20), FlxG.height / 2 + 40, 140);
|
||||||
|
_menu.stI.text = {
|
||||||
|
f: AssetPaths.MrPixel__otf,
|
||||||
|
s: 20,
|
||||||
|
bt: 1,
|
||||||
|
so: [1, 1]
|
||||||
|
};
|
||||||
|
_menu.PARAMS.enable_mouse = false;
|
||||||
|
_menu.stI.col_t = {
|
||||||
|
idle: Pal_DB32.COL[21],
|
||||||
|
focus: Pal_DB32.COL[28],
|
||||||
|
accent: Pal_DB32.COL[29],
|
||||||
|
dis: Pal_DB32.COL[25], // Disabled
|
||||||
|
dis_f: Pal_DB32.COL[23], // Disabled focused
|
||||||
|
};
|
||||||
|
_menu.stI.col_b = {
|
||||||
|
idle: Pal_DB32.COL[1],
|
||||||
|
focus: Pal_DB32.COL[0]
|
||||||
|
};
|
||||||
|
_menu.stHeader = {
|
||||||
|
f: AssetPaths.MrPixel__otf,
|
||||||
|
s: 16,
|
||||||
|
bt: 2,
|
||||||
|
bs: 1,
|
||||||
|
c: Pal_DB32.COL[8],
|
||||||
|
bc: Pal_DB32.COL[27]
|
||||||
|
};
|
||||||
|
_menu.PARAMS.header_CPS = 30;
|
||||||
|
_menu.PARAMS.page_anim_parallel = true;
|
||||||
|
_menu.createPage('main').addM(['Start |link|gamestart', 'Credits |link|credits', 'Exit |link|exit']);
|
||||||
|
|
||||||
|
_menu.onItemEvent = (a, b) ->
|
||||||
|
{
|
||||||
|
if (a == fire)
|
||||||
|
{
|
||||||
|
switch (b.ID)
|
||||||
|
{
|
||||||
|
case 'gamestart': this.switchState(new Level1());
|
||||||
|
case 'credits': this.switchState(new Credits());
|
||||||
|
case 'exit': System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
add(_menu);
|
||||||
|
_menu.goto('main');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function switchState(state)
|
||||||
|
{
|
||||||
|
FlxG.switchState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user