Initial Commit
* Adds Menu * Adds Level Manager - LevelBase * Adds Sample level * Basic player movement
This commit is contained in:
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