1- package ;
1+ package funkin ;
22
3- import flixel .FlxG ;
3+ import flixel .FlxBasic ;
44import flixel .FlxGame ;
5- import flixel .FlxSprite ;
65import flixel .util .typeLimit .NextState ;
7- import funkin .data .save .Save ;
86import funkin .objects .ui .PerformanceStats ;
97import funkin .states .ui .TitleState ;
108import lime .utils .Assets as LimeAssets ;
11- import openfl .display .Sprite ;
129import openfl .utils .Assets as OpenFlAssets ;
1310#if FUNKIN_DISCORD_RPC
1411import funkin .api .DiscordRPC ;
1512#end
1613
17- class Main extends Sprite
14+ class FunkinGame extends FlxGame
1815{
16+ /**
17+ * The current instance of `FunkinGame`.
18+ */
19+ public static var instance : FunkinGame ;
20+
1921 /**
2022 * The FPS and Memory overlay at the top left of the screen.
2123 */
22- public static var performanceStats : PerformanceStats ;
24+ public var performanceStats : PerformanceStats ;
2325
2426 final flxGameData : FlxGameInit = {
2527 width : 1280 ,
@@ -32,16 +34,15 @@ class Main extends Sprite
3234
3335 public function new ()
3436 {
35- super ();
37+ super (flxGameData .width , flxGameData .height , flxGameData .initState , flxGameData .framerate , flxGameData .framerate , ! flxGameData .showSplash ,
38+ flxGameData .startFullscreen );
3639
37- initGame () ;
40+ instance = this ;
3841 }
3942
40- function initGame ( ): Void
43+ override function create ( _ ): Void
4144 {
42- var flxGame : FlxGame = new FlxGame (flxGameData .width , flxGameData .height , flxGameData .initState , flxGameData .framerate , flxGameData .framerate ,
43- ! flxGameData .showSplash , flxGameData .startFullscreen );
44- addChild (flxGame );
45+ super .create (_ );
4546
4647 performanceStats = new PerformanceStats ();
4748 addChild (performanceStats );
@@ -69,6 +70,58 @@ class Main extends Sprite
6970 stage .window .onClose .add (closeWindow );
7071 }
7172
73+ override function onEnterFrame (_ ): Void
74+ {
75+ ticks = getTicks ();
76+ _elapsedMS = ticks - _total ;
77+ _total = ticks ;
78+
79+ if (soundTray != null && soundTray .active )
80+ soundTray .update (_elapsedMS );
81+
82+ if (performanceStats != null )
83+ performanceStats .update (_elapsedMS / 1000 );
84+
85+ if (_lostFocus && FlxG .autoPause )
86+ return ;
87+
88+ if (FlxG .vcr .paused )
89+ {
90+ if (FlxG .vcr .stepRequested )
91+ {
92+ FlxG .vcr .stepRequested = false ;
93+ }
94+ else if (_nextState == null )
95+ {
96+ #if FLX_DEBUG
97+ debugger .update ();
98+ // If the interactive debug is active, the screen must
99+ // be rendered because the user might be doing changes
100+ // to game objects (e.g. moving things around).
101+ if (debugger .interaction .isActive ())
102+ {
103+ draw ();
104+ }
105+ #end
106+
107+ return ;
108+ }
109+ }
110+
111+ step ();
112+
113+ #if FLX_DEBUG
114+ FlxBasic .visibleCount = 0 ;
115+ #end
116+
117+ draw ();
118+
119+ #if FLX_DEBUG
120+ debugger .stats .visibleObjects (FlxBasic .visibleCount );
121+ debugger .update ();
122+ #end
123+ }
124+
72125 /**
73126 * Called when the game gets closed.
74127 */
0 commit comments