2020-10-03 02:50:15 -04:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxGame;
|
2021-02-16 01:53:25 -05:00
|
|
|
import flixel.FlxState;
|
2021-08-17 01:20:00 -04:00
|
|
|
import flixel.util.FlxColor;
|
2021-02-16 01:53:25 -05:00
|
|
|
import openfl.Assets;
|
|
|
|
import openfl.Lib;
|
2020-10-04 02:42:58 -04:00
|
|
|
import openfl.display.FPS;
|
2020-10-03 02:50:15 -04:00
|
|
|
import openfl.display.Sprite;
|
2021-03-04 19:36:56 -05:00
|
|
|
import openfl.events.AsyncErrorEvent;
|
2021-02-16 01:53:25 -05:00
|
|
|
import openfl.events.Event;
|
2021-03-04 19:36:56 -05:00
|
|
|
import openfl.events.MouseEvent;
|
|
|
|
import openfl.events.NetStatusEvent;
|
|
|
|
import openfl.media.Video;
|
|
|
|
import openfl.net.NetConnection;
|
|
|
|
import openfl.net.NetStream;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
|
|
|
class Main extends Sprite
|
|
|
|
{
|
2021-02-16 01:53:25 -05:00
|
|
|
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
|
|
|
|
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
|
|
|
|
var initialState:Class<FlxState> = TitleState; // The FlxState the game starts with.
|
|
|
|
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
|
2021-03-13 13:37:59 -05:00
|
|
|
#if web
|
2021-02-16 01:53:25 -05:00
|
|
|
var framerate:Int = 60; // How many frames per second the game should run at.
|
2021-03-13 13:37:59 -05:00
|
|
|
#else
|
|
|
|
var framerate:Int = 144; // How many frames per second the game should run at.
|
|
|
|
|
|
|
|
#end
|
2021-02-16 01:53:25 -05:00
|
|
|
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
|
|
|
|
var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets
|
|
|
|
|
|
|
|
// You can pretty much ignore everything from here on - your code should go in your states.
|
|
|
|
|
|
|
|
public static function main():Void
|
|
|
|
{
|
|
|
|
Lib.current.addChild(new Main());
|
|
|
|
}
|
|
|
|
|
2020-10-03 02:50:15 -04:00
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super();
|
2021-02-16 01:53:25 -05:00
|
|
|
|
2021-05-15 10:30:09 -04:00
|
|
|
#if polymod
|
|
|
|
polymod.Polymod.init({
|
|
|
|
modRoot: "mods",
|
|
|
|
dirs: ['testing123'],
|
|
|
|
frameworkParams: {
|
|
|
|
assetLibraryPaths: [
|
|
|
|
"songs" => "songs", "shared" => "shared", "tutorial" => "tutorial", "week1" => "week1", "week2" => "week2", "week3" => "week3",
|
2021-09-06 14:50:04 -04:00
|
|
|
"week4" => "week4", "week5" => "week5", "week6" => "week6", "week7" => "week7", "week8" => "week8"
|
2021-05-15 10:30:09 -04:00
|
|
|
]
|
|
|
|
},
|
2021-05-15 12:00:21 -04:00
|
|
|
framework: OPENFL,
|
|
|
|
errorCallback: function(error:polymod.Polymod.PolymodError)
|
|
|
|
{
|
|
|
|
trace("POLYMOD ERROR! code = "
|
|
|
|
+ error.code
|
|
|
|
+ " severity = "
|
|
|
|
+ error.severity
|
|
|
|
+ " origin = "
|
|
|
|
+ error.origin
|
|
|
|
+ " message = "
|
|
|
|
+ error.message);
|
|
|
|
}
|
2021-05-15 10:30:09 -04:00
|
|
|
});
|
|
|
|
#end
|
|
|
|
|
2021-02-16 01:53:25 -05:00
|
|
|
if (stage != null)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addEventListener(Event.ADDED_TO_STAGE, init);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function init(?E:Event):Void
|
|
|
|
{
|
|
|
|
if (hasEventListener(Event.ADDED_TO_STAGE))
|
|
|
|
{
|
|
|
|
removeEventListener(Event.ADDED_TO_STAGE, init);
|
|
|
|
}
|
|
|
|
|
|
|
|
setupGame();
|
|
|
|
}
|
|
|
|
|
2021-03-04 19:36:56 -05:00
|
|
|
var video:Video;
|
|
|
|
var netStream:NetStream;
|
|
|
|
private var overlay:Sprite;
|
|
|
|
|
2021-03-30 23:51:17 -04:00
|
|
|
public static var fpsCounter:FPS;
|
|
|
|
|
2021-02-16 01:53:25 -05:00
|
|
|
private function setupGame():Void
|
|
|
|
{
|
2021-08-17 01:20:00 -04:00
|
|
|
// Lib.current.stage.color = null;
|
|
|
|
|
2021-02-16 01:53:25 -05:00
|
|
|
var stageWidth:Int = Lib.current.stage.stageWidth;
|
|
|
|
var stageHeight:Int = Lib.current.stage.stageHeight;
|
|
|
|
|
|
|
|
if (zoom == -1)
|
|
|
|
{
|
|
|
|
var ratioX:Float = stageWidth / gameWidth;
|
|
|
|
var ratioY:Float = stageHeight / gameHeight;
|
|
|
|
zoom = Math.min(ratioX, ratioY);
|
|
|
|
gameWidth = Math.ceil(stageWidth / zoom);
|
|
|
|
gameHeight = Math.ceil(stageHeight / zoom);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !debug
|
|
|
|
initialState = TitleState;
|
|
|
|
#end
|
|
|
|
|
|
|
|
addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
|
2020-10-04 02:42:58 -04:00
|
|
|
|
|
|
|
#if !mobile
|
2021-03-30 23:51:17 -04:00
|
|
|
fpsCounter = new FPS(10, 3, 0xFFFFFF);
|
|
|
|
addChild(fpsCounter);
|
2020-10-04 02:42:58 -04:00
|
|
|
#end
|
2021-03-04 19:36:56 -05:00
|
|
|
/*
|
|
|
|
video = new Video();
|
|
|
|
addChild(video);
|
|
|
|
|
|
|
|
var netConnection = new NetConnection();
|
|
|
|
netConnection.connect(null);
|
|
|
|
|
|
|
|
netStream = new NetStream(netConnection);
|
|
|
|
netStream.client = {onMetaData: client_onMetaData};
|
|
|
|
netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError);
|
|
|
|
|
|
|
|
#if (js && html5)
|
|
|
|
overlay = new Sprite();
|
|
|
|
overlay.graphics.beginFill(0, 0.5);
|
|
|
|
overlay.graphics.drawRect(0, 0, 560, 320);
|
|
|
|
overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown);
|
|
|
|
overlay.buttonMode = true;
|
|
|
|
addChild(overlay);
|
|
|
|
|
|
|
|
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus);
|
|
|
|
#else
|
|
|
|
netStream.play("assets/preload/music/dredd.mp4");
|
|
|
|
#end
|
|
|
|
*/
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|
2021-03-04 19:36:56 -05:00
|
|
|
/*
|
|
|
|
private function client_onMetaData(metaData:Dynamic)
|
|
|
|
{
|
|
|
|
video.attachNetStream(netStream);
|
|
|
|
|
|
|
|
video.width = video.videoWidth;
|
|
|
|
video.height = video.videoHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function netStream_onAsyncError(event:AsyncErrorEvent):Void
|
|
|
|
{
|
|
|
|
trace("Error loading video");
|
|
|
|
}
|
|
|
|
|
|
|
|
private function netConnection_onNetStatus(event:NetStatusEvent):Void
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private function overlay_onMouseDown(event:MouseEvent):Void
|
|
|
|
{
|
|
|
|
netStream.play("assets/preload/music/dredd.mp4");
|
|
|
|
}
|
|
|
|
*/
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|