Funkin/source/TitleState.hx

749 lines
19 KiB
Haxe
Raw Normal View History

2020-10-05 14:24:51 -04:00
package;
2021-04-08 20:48:11 -04:00
import flixel.FlxGame;
import flixel.FlxObject;
2020-10-05 14:24:51 -04:00
import flixel.FlxSprite;
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.transition.TransitionData;
import flixel.graphics.FlxGraphic;
2020-10-21 02:23:39 -04:00
import flixel.group.FlxGroup;
2020-10-09 03:29:00 -04:00
import flixel.input.gamepad.FlxGamepad;
import flixel.input.gamepad.id.SwitchJoyconLeftID;
2020-10-05 14:24:51 -04:00
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxGraphicAsset;
import flixel.system.FlxAssets;
2021-06-04 02:01:34 -04:00
import flixel.text.FlxText;
2020-10-05 14:24:51 -04:00
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import lime.app.Application;
import lime.graphics.Image;
import lime.media.AudioContext;
import lime.ui.Window;
2021-01-24 22:42:51 -05:00
import openfl.Assets;
2021-08-22 10:37:06 -04:00
import openfl.display.BitmapData;
2021-04-09 19:17:14 -04:00
import openfl.display.Sprite;
import openfl.events.AsyncErrorEvent;
import openfl.events.AsyncErrorEvent;
import openfl.events.Event;
import openfl.events.MouseEvent;
import openfl.events.NetStatusEvent;
import openfl.media.Video;
import openfl.net.NetConnection;
import openfl.net.NetStream;
2021-04-18 01:43:28 -04:00
import shaderslmfao.BuildingShaders.BuildingShader;
import shaderslmfao.BuildingShaders;
2021-03-20 14:55:29 -04:00
import shaderslmfao.ColorSwap;
2021-08-17 01:20:00 -04:00
import shaderslmfao.TitleOutline;
2021-03-26 21:22:07 -04:00
import ui.PreferencesMenu;
2021-05-16 19:17:58 -04:00
import ui.stageBuildShit.StageBuilderState;
2020-10-05 14:24:51 -04:00
using StringTools;
2021-07-14 19:00:22 -04:00
#if colyseus
import io.colyseus.Client;
import io.colyseus.Room;
#end
2021-03-22 10:09:46 -04:00
#if discord_rpc
2021-03-20 14:55:29 -04:00
import Discord.DiscordClient;
2021-03-22 10:09:46 -04:00
#end
#if desktop
2021-04-06 12:27:07 -04:00
import sys.FileSystem;
import sys.io.File;
2021-03-20 14:55:29 -04:00
import sys.thread.Thread;
#end
2020-10-21 02:23:39 -04:00
class TitleState extends MusicBeatState
2020-10-05 14:24:51 -04:00
{
2021-04-18 04:09:56 -04:00
public static var initialized:Bool = false;
2020-10-05 14:24:51 -04:00
2021-04-22 15:36:56 -04:00
var startedIntro:Bool;
2020-10-05 14:24:51 -04:00
2020-10-21 02:23:39 -04:00
var blackScreen:FlxSprite;
var credGroup:FlxGroup;
2020-10-30 19:47:19 -04:00
var credTextShit:Alphabet;
var textGroup:FlxGroup;
2020-10-31 21:11:14 -04:00
var ngSpr:FlxSprite;
var curWacky:Array<String> = [];
2020-11-02 17:40:12 -05:00
var wackyImage:FlxSprite;
var lastBeat:Int = 0;
2021-03-21 14:45:46 -04:00
var swagShader:ColorSwap;
2021-04-18 01:43:28 -04:00
var alphaShader:BuildingShaders;
var thingie:FlxSprite;
2021-04-09 19:17:14 -04:00
var video:Video;
var netStream:NetStream;
private var overlay:Sprite;
2020-10-05 14:24:51 -04:00
override public function create():Void
{
2021-08-22 10:37:06 -04:00
FlxG.debugger.addButton(LEFT, new BitmapData(200, 200), function()
{
FlxG.debugger.visible = false;
});
2021-04-22 15:36:56 -04:00
startedIntro = false;
2021-04-08 20:48:11 -04:00
FlxG.game.focusLostFramerate = 60;
2021-03-21 14:45:46 -04:00
swagShader = new ColorSwap();
2021-04-18 01:43:28 -04:00
alphaShader = new BuildingShaders();
2021-03-20 15:20:00 -04:00
2021-03-13 13:37:59 -05:00
FlxG.sound.muteKeys = [ZERO];
2020-11-16 15:29:18 -05:00
curWacky = FlxG.random.getObject(getIntroTextShit());
2021-05-14 18:21:34 -04:00
FlxG.sound.cache(Paths.music('freakyMenu'));
2020-10-31 21:11:14 -04:00
2020-10-30 19:47:19 -04:00
// DEBUG BULLSHIT
2020-10-05 14:24:51 -04:00
super.create();
2020-11-06 21:17:27 -05:00
FlxG.save.bind('funkin', 'ninjamuffin99');
2021-03-30 23:51:17 -04:00
PreferencesMenu.initPrefs();
2021-03-22 22:39:35 -04:00
PlayerSettings.init();
2020-11-06 21:17:27 -05:00
Highscore.load();
2021-03-24 18:41:54 -04:00
2021-03-27 19:11:14 -04:00
#if newgrounds
2021-02-19 21:11:33 -05:00
NGio.init();
#end
2021-03-24 18:41:54 -04:00
2020-11-06 21:17:27 -05:00
if (FlxG.save.data.weekUnlocked != null)
{
2020-12-27 05:57:45 -05:00
// FIX LATER!!!
// WEEK UNLOCK PROGRESSION!!
// StoryMenuState.weekUnlocked = FlxG.save.data.weekUnlocked;
2020-11-06 21:17:27 -05:00
2020-12-11 04:15:24 -05:00
if (StoryMenuState.weekUnlocked.length < 4)
2020-12-11 08:49:06 -05:00
StoryMenuState.weekUnlocked.insert(0, true);
// QUICK PATCH OOPS!
if (!StoryMenuState.weekUnlocked[0])
StoryMenuState.weekUnlocked[0] = true;
2020-11-06 21:17:27 -05:00
}
2021-04-18 03:47:48 -04:00
if (FlxG.save.data.seenVideo != null)
{
VideoState.seenVideo = FlxG.save.data.seenVideo;
}
2020-12-26 21:46:22 -05:00
#if FREEPLAY
FlxG.switchState(new FreeplayState());
2021-04-14 11:31:52 -04:00
#elseif ANIMATE
2021-06-15 17:43:46 -04:00
FlxG.switchState(new animate.AnimTestStage());
2020-12-26 21:46:22 -05:00
#elseif CHARTING
2020-12-21 17:20:57 -05:00
FlxG.switchState(new ChartingState());
2021-04-10 02:53:23 -04:00
/*
#elseif web
2021-04-09 19:17:14 -04:00
2021-04-10 02:53:23 -04:00
if (!initialized)
{
2021-04-09 19:17:14 -04:00
2021-04-10 02:53:23 -04:00
video = new Video();
FlxG.stage.addChild(video);
2021-04-09 19:17:14 -04:00
2021-04-10 02:53:23 -04:00
var netConnection = new NetConnection();
netConnection.connect(null);
netStream = new NetStream(netConnection);
netStream.client = {onMetaData: client_onMetaData};
netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError);
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus);
// netStream.addEventListener(NetStatusEvent.NET_STATUS) // netStream.play(Paths.file('music/kickstarterTrailer.mp4'));
overlay = new Sprite();
overlay.graphics.beginFill(0, 0.5);
overlay.graphics.drawRect(0, 0, 1280, 720);
overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown);
overlay.buttonMode = true;
// FlxG.stage.addChild(overlay);
}
*/
2021-04-09 19:17:14 -04:00
// netConnection.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown);
2021-05-16 19:17:58 -04:00
#elseif STAGEBUILD
FlxG.switchState(new StageBuilderState());
2021-05-26 19:22:15 -04:00
#elseif ANIMDEBUG
2021-06-04 12:53:53 -04:00
FlxG.switchState(new ui.animDebugShit.DebugBoundingState());
2021-07-14 19:00:22 -04:00
#elseif NETTEST
FlxG.switchState(new netTest.NetTest());
2020-10-30 19:47:19 -04:00
#else
2021-02-14 19:45:18 -05:00
new FlxTimer().start(1, function(tmr:FlxTimer)
{
startIntro();
});
2020-10-30 19:47:19 -04:00
#end
2021-02-26 07:27:32 -05:00
2021-03-22 10:09:46 -04:00
#if discord_rpc
2021-02-26 07:27:32 -05:00
DiscordClient.initialize();
2021-04-09 19:17:14 -04:00
Application.current.onExit.add(function(exitCode)
{
2021-04-02 17:35:14 -04:00
DiscordClient.shutdown();
2021-04-09 19:17:14 -04:00
});
2021-02-26 07:27:32 -05:00
#end
// FlxG.stage.window.borderless = true;
// FlxG.stage.window.mouseLock = true;
2020-10-30 19:47:19 -04:00
}
2021-04-09 19:17:14 -04:00
private function client_onMetaData(metaData:Dynamic)
{
video.attachNetStream(netStream);
video.width = video.videoWidth;
video.height = video.videoHeight;
2021-04-09 22:49:25 -04:00
// video.
2021-04-09 19:17:14 -04:00
}
private function netStream_onAsyncError(event:AsyncErrorEvent):Void
{
trace("Error loading video");
}
private function netConnection_onNetStatus(event:NetStatusEvent):Void
{
if (event.info.code == 'NetStream.Play.Complete')
{
2021-04-10 02:53:23 -04:00
// netStream.dispose();
// FlxG.stage.removeChild(video);
2021-04-09 19:17:14 -04:00
startIntro();
}
trace(event.toString());
}
private function overlay_onMouseDown(event:MouseEvent):Void
{
2021-04-09 22:49:25 -04:00
netStream.soundTransform.volume = 0.2;
netStream.soundTransform.pan = -1;
2021-04-10 02:53:23 -04:00
// netStream.play(Paths.file('music/kickstarterTrailer.mp4'));
2021-04-09 22:49:25 -04:00
2021-04-09 19:17:14 -04:00
FlxG.stage.removeChild(overlay);
}
2020-11-01 14:16:22 -05:00
var logoBl:FlxSprite;
2021-08-18 23:00:39 -04:00
var outlineShaderShit:TitleOutline;
2021-04-09 19:17:14 -04:00
2020-11-01 14:16:22 -05:00
var gfDance:FlxSprite;
var danceLeft:Bool = false;
var titleText:FlxSprite;
2020-10-30 19:47:19 -04:00
function startIntro()
{
2020-10-05 14:24:51 -04:00
if (!initialized)
{
var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond);
diamond.persist = true;
diamond.destroyOnNoUse = false;
2020-10-31 21:11:14 -04:00
FlxTransitionableState.defaultTransIn = new TransitionData(FADE, FlxColor.BLACK, 1, new FlxPoint(0, -1), {asset: diamond, width: 32, height: 32},
2021-01-20 04:11:55 -05:00
new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
2020-10-31 21:11:14 -04:00
FlxTransitionableState.defaultTransOut = new TransitionData(FADE, FlxColor.BLACK, 0.7, new FlxPoint(0, 1),
2021-01-20 04:11:55 -05:00
{asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
2021-04-22 15:36:56 -04:00
}
2020-10-05 14:24:51 -04:00
2021-04-22 15:36:56 -04:00
if (FlxG.sound.music == null || !FlxG.sound.music.playing)
{
2021-02-08 16:34:48 -05:00
FlxG.sound.playMusic(Paths.music('freakyMenu'), 0);
2020-10-31 21:11:14 -04:00
FlxG.sound.music.fadeIn(4, 0, 0.7);
2020-10-05 14:24:51 -04:00
}
2020-11-01 14:16:22 -05:00
Conductor.changeBPM(102);
2020-10-05 14:24:51 -04:00
persistentUpdate = true;
2020-11-01 14:16:22 -05:00
var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
// bg.antialiasing = true;
// bg.setGraphicSize(Std.int(bg.width * 0.6));
// bg.updateHitbox();
2021-03-20 00:48:17 -04:00
2020-10-05 14:24:51 -04:00
add(bg);
2020-11-01 14:16:22 -05:00
logoBl = new FlxSprite(-150, -100);
2021-02-08 16:34:48 -05:00
logoBl.frames = Paths.getSparrowAtlas('logoBumpin');
2020-11-01 14:16:22 -05:00
logoBl.antialiasing = true;
logoBl.animation.addByPrefix('bump', 'logo bumpin', 24);
logoBl.animation.play('bump');
2021-04-06 18:12:31 -04:00
2020-11-01 14:16:22 -05:00
logoBl.updateHitbox();
2021-03-20 00:48:17 -04:00
2021-08-18 23:00:39 -04:00
outlineShaderShit = new TitleOutline();
2021-08-17 01:20:00 -04:00
// logoBl.shader = swagShader.shader;
2021-08-21 19:53:08 -04:00
// logoBl.shader = outlineShaderShit;
2021-04-18 01:43:28 -04:00
// logoBl.shader = alphaShader.shader;
2021-03-20 15:20:00 -04:00
2021-03-20 00:48:17 -04:00
// trace();
2020-11-01 14:16:22 -05:00
// logoBl.screenCenter();
// logoBl.color = FlxColor.BLACK;
gfDance = new FlxSprite(FlxG.width * 0.4, FlxG.height * 0.07);
2021-02-08 16:34:48 -05:00
gfDance.frames = Paths.getSparrowAtlas('gfDanceTitle');
2020-11-01 14:16:22 -05:00
gfDance.animation.addByIndices('danceLeft', 'gfDance', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
gfDance.animation.addByIndices('danceRight', 'gfDance', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24, false);
gfDance.antialiasing = true;
add(gfDance);
2021-03-20 14:55:29 -04:00
2021-08-21 19:53:08 -04:00
// gfDance.shader = swagShader.shader;
2021-03-20 14:55:29 -04:00
2021-08-17 01:20:00 -04:00
// gfDance.shader = new TitleOutline();
2020-10-05 14:24:51 -04:00
add(logoBl);
2020-11-01 14:16:22 -05:00
titleText = new FlxSprite(100, FlxG.height * 0.8);
2021-02-08 16:34:48 -05:00
titleText.frames = Paths.getSparrowAtlas('titleEnter');
2020-11-01 14:16:22 -05:00
titleText.animation.addByPrefix('idle', "Press Enter to Begin", 24);
titleText.animation.addByPrefix('press', "ENTER PRESSED", 24);
titleText.antialiasing = true;
titleText.animation.play('idle');
titleText.updateHitbox();
// titleText.screenCenter(X);
add(titleText);
2021-02-08 16:34:48 -05:00
var logo:FlxSprite = new FlxSprite().loadGraphic(Paths.image('logo'));
2020-10-05 14:24:51 -04:00
logo.screenCenter();
2020-10-05 18:29:59 -04:00
logo.antialiasing = true;
2020-11-01 14:16:22 -05:00
// add(logo);
2020-10-05 14:24:51 -04:00
2020-11-01 14:16:22 -05:00
// FlxTween.tween(logoBl, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG});
// FlxTween.tween(logo, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG, startDelay: 0.1});
2021-07-14 20:32:09 -04:00
var animShit:ComboCounter = new ComboCounter(200, 200, 1423);
2021-08-17 01:20:00 -04:00
// add(animShit);
2020-10-21 02:23:39 -04:00
credGroup = new FlxGroup();
add(credGroup);
2021-07-14 20:32:09 -04:00
2020-10-30 19:47:19 -04:00
textGroup = new FlxGroup();
2020-10-21 02:23:39 -04:00
blackScreen = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
credGroup.add(blackScreen);
2021-03-31 13:08:55 -04:00
// var atlasBullShit:FlxSprite = new FlxSprite();
// atlasBullShit.frames = CoolUtil.fromAnimate(Paths.image('money'), Paths.file('images/money.json'));
// credGroup.add(atlasBullShit);
2020-10-30 19:47:19 -04:00
credTextShit = new Alphabet(0, 0, "ninjamuffin99\nPhantomArcade\nkawaisprite\nevilsk8er", true);
2020-10-21 02:23:39 -04:00
credTextShit.screenCenter();
2020-10-30 19:47:19 -04:00
// credTextShit.alignment = CENTER;
2020-10-21 02:23:39 -04:00
credTextShit.visible = false;
2021-05-14 17:53:34 -04:00
ngSpr = new FlxSprite(0, FlxG.height * 0.52);
if (FlxG.random.bool(1))
{
ngSpr.loadGraphic(Paths.image('newgrounds_logo_classic'));
}
else if (FlxG.random.bool(30))
{
ngSpr.loadGraphic(Paths.image('newgrounds_logo_animated'), true, 600);
ngSpr.animation.add('idle', [0, 1], 4);
ngSpr.animation.play('idle');
ngSpr.setGraphicSize(Std.int(ngSpr.width * 0.55));
}
else
{
ngSpr.loadGraphic(Paths.image('newgrounds_logo'));
ngSpr.setGraphicSize(Std.int(ngSpr.width * 0.8));
}
2020-10-31 21:11:14 -04:00
add(ngSpr);
ngSpr.visible = false;
2021-05-14 17:53:34 -04:00
2020-10-31 21:11:14 -04:00
ngSpr.updateHitbox();
ngSpr.screenCenter(X);
ngSpr.antialiasing = true;
2020-10-21 02:23:39 -04:00
2020-10-31 21:11:14 -04:00
FlxTween.tween(credTextShit, {y: credTextShit.y + 20}, 2.9, {ease: FlxEase.quadInOut, type: PINGPONG});
2020-10-21 02:23:39 -04:00
2020-11-01 14:16:22 -05:00
FlxG.mouse.visible = false;
2020-10-31 21:11:14 -04:00
if (initialized)
skipIntro();
else
initialized = true;
2020-10-05 14:24:51 -04:00
2021-04-10 02:53:23 -04:00
if (FlxG.sound.music != null)
FlxG.sound.music.onComplete = function() FlxG.switchState(new VideoState());
2021-04-22 15:36:56 -04:00
startedIntro = true;
2020-10-31 21:11:14 -04:00
// credGroup.add(credTextShit);
2020-10-05 14:24:51 -04:00
}
2020-11-16 15:29:18 -05:00
function getIntroTextShit():Array<Array<String>>
{
var fullText:String = Assets.getText(Paths.txt('introText'));
2020-11-16 15:29:18 -05:00
var firstArray:Array<String> = fullText.split('\n');
var swagGoodArray:Array<Array<String>> = [];
for (i in firstArray)
{
swagGoodArray.push(i.split('--'));
}
return swagGoodArray;
}
2020-10-05 14:24:51 -04:00
var transitioning:Bool = false;
2021-08-17 01:20:00 -04:00
var fnfShit:String = "Friday Night Funkin'";
var thingOffset:Int = 0;
2020-10-05 14:24:51 -04:00
override function update(elapsed:Float)
{
2021-08-21 19:53:08 -04:00
/* if (FlxG.onMobile)
{
if (gfDance != null)
{
gfDance.x = (FlxG.width / 2) + (FlxG.accelerometer.x * (FlxG.width / 2));
// gfDance.y = (FlxG.height / 2) + (FlxG.accelerometer.y * (FlxG.height / 2));
}
}
*/
2021-08-18 23:00:39 -04:00
if (FlxG.keys.justPressed.I)
{
FlxTween.tween(outlineShaderShit, {funnyX: 50, funnyY: 50}, 0.6, {ease: FlxEase.quartOut});
}
if (FlxG.keys.pressed.D)
outlineShaderShit.funnyX += 1;
// outlineShaderShit.xPos.value[0] += 1;
2021-07-14 19:00:22 -04:00
if (FlxG.keys.justPressed.Y)
{
FlxTween.tween(FlxG.stage.window, {x: FlxG.stage.window.x + 300}, 1.4, {ease: FlxEase.quadInOut, type: PINGPONG, startDelay: 0.35});
FlxTween.tween(FlxG.stage.window, {y: FlxG.stage.window.y + 100}, 0.7, {ease: FlxEase.quadInOut, type: PINGPONG});
}
/*
FlxG.watch.addQuick('cur display', FlxG.stage.window.display.id);
if (FlxG.keys.justPressed.Y)
{
// trace(FlxG.stage.window.display.name);
if (FlxG.gamepads.firstActive != null)
{
trace(FlxG.gamepads.firstActive.model);
FlxG.gamepads.firstActive.id
}
else
trace('gamepad null');
// FlxG.stage.window.title = Std.string(FlxG.random.int(0, 20000));
// FlxG.stage.window.setIcon(Image.fromFile('assets/images/icon16.png'));
// FlxG.stage.window.readPixels;
if (FlxG.stage.window.width == Std.int(FlxG.stage.window.display.bounds.width))
{
FlxG.stage.window.width = 1280;
FlxG.stage.window.height = 720;
FlxG.stage.window.y = 30;
}
else
{
FlxG.stage.window.width = Std.int(FlxG.stage.window.display.bounds.width);
FlxG.stage.window.height = Std.int(FlxG.stage.window.display.bounds.height);
FlxG.stage.window.x = Std.int(FlxG.stage.window.display.bounds.x);
FlxG.stage.window.y = Std.int(FlxG.stage.window.display.bounds.y);
}
}
*/
2021-04-22 15:36:56 -04:00
#if debug
2021-04-06 18:12:31 -04:00
if (FlxG.keys.justPressed.EIGHT)
FlxG.switchState(new CutsceneAnimTestState());
2021-04-22 15:36:56 -04:00
#end
2021-04-06 18:12:31 -04:00
2021-03-10 00:27:57 -05:00
/*
if (FlxG.keys.justPressed.R)
{
#if polymod
polymod.Polymod.init({modRoot: "mods", dirs: ['introMod']});
trace('reinitialized');
#end
}
*/
2021-02-14 19:45:18 -05:00
if (FlxG.sound.music != null)
Conductor.songPosition = FlxG.sound.music.time;
2020-11-06 21:17:27 -05:00
// FlxG.watch.addQuick('amp', FlxG.sound.music.amplitude);
if (FlxG.keys.justPressed.F)
FlxG.fullscreen = !FlxG.fullscreen;
2020-10-09 03:29:00 -04:00
var pressedEnter:Bool = FlxG.keys.justPressed.ENTER;
2021-02-23 23:32:53 -05:00
#if mobile
for (touch in FlxG.touches.list)
{
if (touch.justPressed)
2021-08-17 01:20:00 -04:00
{
FlxG.switchState(new FreeplayState());
2021-02-23 23:32:53 -05:00
pressedEnter = true;
2021-08-17 01:20:00 -04:00
}
2021-02-23 23:32:53 -05:00
}
#end
2020-10-09 03:29:00 -04:00
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.START)
pressedEnter = true;
2020-11-03 04:12:13 -05:00
#if switch
if (gamepad.justPressed.B)
pressedEnter = true;
#end
2020-10-09 03:29:00 -04:00
}
2020-10-21 14:05:27 -04:00
if (pressedEnter && !transitioning && skippedIntro)
2020-10-05 14:24:51 -04:00
{
2021-04-10 02:53:23 -04:00
if (FlxG.sound.music != null)
FlxG.sound.music.onComplete = null;
// netStream.play(Paths.file('music/kickstarterTrailer.mp4'));
2020-11-01 14:16:22 -05:00
NGio.unlockMedal(60960);
2020-11-06 21:17:27 -05:00
// If it's Friday according to da clock
if (Date.now().getDay() == 5)
NGio.unlockMedal(61034);
2020-11-01 14:16:22 -05:00
titleText.animation.play('press');
2020-10-05 14:33:56 -04:00
FlxG.camera.flash(FlxColor.WHITE, 1);
2021-02-08 16:34:48 -05:00
FlxG.sound.play(Paths.sound('confirmMenu'), 0.7);
2020-10-05 14:24:51 -04:00
transitioning = true;
2020-10-31 21:11:14 -04:00
// FlxG.sound.music.stop();
2021-06-08 23:05:38 -04:00
// These assets are very unlikely to be used for the rest of gameplay, so it unloads them from cache/memory
// Saves about 50mb of RAM or so???
Assets.cache.clear(Paths.image('gfDanceTitle'));
Assets.cache.clear(Paths.image('logoBumpin'));
Assets.cache.clear(Paths.image('titleEnter'));
2021-03-27 19:11:14 -04:00
#if newgrounds
2021-02-18 14:58:16 -05:00
if (!OutdatedSubState.leftState)
2020-10-05 14:24:51 -04:00
{
2021-02-18 14:58:16 -05:00
NGio.checkVersion(function(version)
{
2021-02-18 14:58:16 -05:00
// Check if version is outdated
var localVersion:String = "v" + Application.current.meta.get('version');
var onlineVersion = version.split(" ")[0].trim();
if (version.trim() != onlineVersion)
{
trace('OLD VERSION!');
2021-04-18 13:23:09 -04:00
// FlxG.switchState(new OutdatedSubState());
2021-02-18 14:58:16 -05:00
}
else
{
2021-04-18 13:23:09 -04:00
// FlxG.switchState(new MainMenuState());
2021-02-18 14:58:16 -05:00
}
2021-04-18 13:23:09 -04:00
// REDO FOR ITCH/FINAL SHIT
FlxG.switchState(new MainMenuState());
2021-02-18 14:58:16 -05:00
});
}
2021-02-19 21:11:33 -05:00
#else
FlxG.switchState(new MainMenuState());
#end
2021-02-08 16:34:48 -05:00
// FlxG.sound.play(Paths.music('titleShoot'), 0.7);
2020-10-31 21:11:14 -04:00
}
if (pressedEnter && !skippedIntro && initialized)
2020-10-31 21:11:14 -04:00
skipIntro();
2021-04-10 02:53:23 -04:00
/*
#if web
if (!initialized && controls.ACCEPT)
{
// netStream.dispose();
// FlxG.stage.removeChild(video);
2020-10-05 14:24:51 -04:00
2021-04-10 02:53:23 -04:00
startIntro();
skipIntro();
}
#end
*/
2021-04-09 19:17:14 -04:00
// if (FlxG.keys.justPressed.SPACE)
// swagShader.hasOutline = !swagShader.hasOutline;
2021-03-23 00:05:46 -04:00
if (controls.UI_LEFT)
2021-03-21 14:45:46 -04:00
swagShader.update(-elapsed * 0.1);
2021-03-23 00:05:46 -04:00
if (controls.UI_RIGHT)
2021-03-21 14:45:46 -04:00
swagShader.update(elapsed * 0.1);
if (!cheatActive && skippedIntro)
cheatCodeShit();
2020-10-05 14:24:51 -04:00
super.update(elapsed);
}
2020-10-21 02:23:39 -04:00
var cheatArray:Array<Int> = [0x0001, 0x0010, 0x0001, 0x0010, 0x0100, 0x1000, 0x0100, 0x1000];
var curCheatPos:Int = 0;
var cheatActive:Bool = false;
function cheatCodeShit():Void
{
if (FlxG.keys.justPressed.ANY)
{
if (controls.NOTE_DOWN_P || controls.UI_DOWN_P)
codePress(FlxObject.DOWN);
if (controls.NOTE_UP_P || controls.UI_UP_P)
codePress(FlxObject.UP);
if (controls.NOTE_LEFT_P || controls.UI_LEFT_P)
codePress(FlxObject.LEFT);
if (controls.NOTE_RIGHT_P || controls.UI_RIGHT_P)
codePress(FlxObject.RIGHT);
}
}
function codePress(input:Int)
{
if (input == cheatArray[curCheatPos])
{
curCheatPos += 1;
if (curCheatPos >= cheatArray.length)
startCheat();
}
else
curCheatPos = 0;
trace(input);
}
function startCheat():Void
{
cheatActive = true;
FlxG.sound.playMusic(Paths.music('tutorialTitle'), 1);
Conductor.changeBPM(190);
FlxG.camera.flash(FlxColor.WHITE, 1);
FlxG.sound.play(Paths.sound('confirmMenu'), 0.7);
}
2020-10-30 19:47:19 -04:00
function createCoolText(textArray:Array<String>)
{
for (i in 0...textArray.length)
{
var money:Alphabet = new Alphabet(0, 0, textArray[i], true, false);
money.screenCenter(X);
money.y += (i * 60) + 200;
credGroup.add(money);
textGroup.add(money);
}
}
function addMoreText(text:String)
{
2021-08-21 19:53:08 -04:00
lime.ui.Haptic.vibrate(100, 100);
2020-10-30 19:47:19 -04:00
var coolText:Alphabet = new Alphabet(0, 0, text, true, false);
coolText.screenCenter(X);
coolText.y += (textGroup.length * 60) + 200;
credGroup.add(coolText);
textGroup.add(coolText);
}
function deleteCoolText()
{
while (textGroup.members.length > 0)
{
credGroup.remove(textGroup.members[0], true);
textGroup.remove(textGroup.members[0], true);
}
}
2021-03-21 14:45:46 -04:00
var isRainbow:Bool = false;
2020-10-21 02:23:39 -04:00
override function beatHit()
{
super.beatHit();
2021-04-22 15:36:56 -04:00
if (skippedIntro)
{
2021-05-14 18:02:29 -04:00
if (cheatActive && curBeat % 2 == 0)
swagShader.update(0.125);
2021-04-22 15:36:56 -04:00
logoBl.animation.play('bump', true);
2020-11-01 14:16:22 -05:00
2021-04-22 15:36:56 -04:00
danceLeft = !danceLeft;
2020-11-01 14:16:22 -05:00
2021-04-22 15:36:56 -04:00
if (danceLeft)
gfDance.animation.play('danceRight');
else
gfDance.animation.play('danceLeft');
}
else
2020-10-21 02:23:39 -04:00
{
2021-04-22 15:36:56 -04:00
FlxG.log.add(curBeat);
// if the user is draggin the window some beats will
// be missed so this is just to compensate
if (curBeat > lastBeat)
{
2021-04-22 15:36:56 -04:00
for (i in lastBeat...curBeat)
{
2021-04-22 15:36:56 -04:00
switch (i + 1)
{
case 1:
createCoolText(['ninjamuffin99', 'phantomArcade', 'kawaisprite', 'evilsk8er']);
// credTextShit.visible = true;
case 3:
addMoreText('present');
// credTextShit.text += '\npresent...';
// credTextShit.addText();
case 4:
deleteCoolText();
// credTextShit.visible = false;
// credTextShit.text = 'In association \nwith';
// credTextShit.screenCenter();
case 5:
createCoolText(['In association', 'with']);
case 7:
addMoreText('newgrounds');
ngSpr.visible = true;
// credTextShit.text += '\nNewgrounds';
case 8:
deleteCoolText();
ngSpr.visible = false;
// credTextShit.visible = false;
// credTextShit.text = 'Shoutouts Tom Fulp';
// credTextShit.screenCenter();
case 9:
createCoolText([curWacky[0]]);
// credTextShit.visible = true;
case 11:
addMoreText(curWacky[1]);
// credTextShit.text += '\nlmao';
case 12:
deleteCoolText();
// credTextShit.visible = false;
// credTextShit.text = "Friday";
// credTextShit.screenCenter();
case 13:
addMoreText('Friday');
// credTextShit.visible = true;
case 14:
addMoreText('Night');
// credTextShit.text += '\nNight';
case 15:
addMoreText('Funkin'); // credTextShit.text += '\nFunkin';
case 16:
skipIntro();
}
}
}
2021-04-22 15:36:56 -04:00
lastBeat = curBeat;
2020-10-21 14:05:27 -04:00
}
}
var skippedIntro:Bool = false;
function skipIntro():Void
{
if (!skippedIntro)
{
2020-10-31 21:11:14 -04:00
remove(ngSpr);
2020-10-21 14:05:27 -04:00
FlxG.camera.flash(FlxColor.WHITE, 4);
remove(credGroup);
2020-10-30 19:47:19 -04:00
skippedIntro = true;
2020-10-21 02:23:39 -04:00
}
}
2020-10-05 14:24:51 -04:00
}