You Are An BoyFriend Hahahahahahahaha!
This commit is contained in:
parent
18552f147f
commit
3c5e0b8d0f
|
@ -6,6 +6,12 @@ import Discord.DiscordClient;
|
|||
|
||||
import flixel.FlxGame;
|
||||
import flixel.FlxState;
|
||||
import flixel.FlxG;
|
||||
import flixel.tweens.FlxEase;
|
||||
import flixel.tweens.FlxEase.EaseFunction;
|
||||
import flixel.tweens.FlxTween;
|
||||
import flixel.tweens.FlxTween.TweenOptions;
|
||||
import flixel.util.FlxTimer;
|
||||
import openfl.Assets;
|
||||
import openfl.Lib;
|
||||
import openfl.display.FPS;
|
||||
|
@ -17,7 +23,9 @@ import openfl.events.NetStatusEvent;
|
|||
import openfl.media.Video;
|
||||
import openfl.net.NetConnection;
|
||||
import openfl.net.NetStream;
|
||||
#if desktop
|
||||
import lime.app.Application;
|
||||
#end
|
||||
|
||||
//crash handler stuff
|
||||
#if ErrorDialog
|
||||
|
@ -39,7 +47,7 @@ class Main extends Sprite
|
|||
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.
|
||||
*/
|
||||
#if web
|
||||
#if (!desktop || !mobile)
|
||||
var game = {
|
||||
width: 1280, // WINDOW width
|
||||
height: 720, // WINDOW height
|
||||
|
@ -131,6 +139,11 @@ class Main extends Sprite
|
|||
#if ErrorDialog
|
||||
Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onCrash);
|
||||
#end
|
||||
|
||||
#if desktop
|
||||
Application.current.window.onFocusOut.add(onWindowFocusOut);
|
||||
Application.current.window.onFocusIn.add(onWindowFocusIn);
|
||||
#end
|
||||
/*
|
||||
video = new Video();
|
||||
addChild(video);
|
||||
|
@ -180,6 +193,76 @@ class Main extends Sprite
|
|||
}
|
||||
*/
|
||||
|
||||
#if desktop
|
||||
var oldVol:Float = 1.0;
|
||||
var newVol:Float = 0.3;
|
||||
|
||||
public static var focused:Bool = true;
|
||||
|
||||
public static var focusMusicTween:FlxTween;
|
||||
|
||||
// thx for ur code ari
|
||||
function onWindowFocusOut()
|
||||
{
|
||||
focused = false;
|
||||
|
||||
// Lower global volume when unfocused
|
||||
if (Type.getClass(FlxG.state) != PlayState) // imagine stealing my code smh
|
||||
{
|
||||
oldVol = FlxG.sound.volume;
|
||||
if (oldVol > 0.3)
|
||||
{
|
||||
newVol = 0.3;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oldVol > 0.1)
|
||||
{
|
||||
newVol = 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
newVol = 0;
|
||||
}
|
||||
}
|
||||
|
||||
trace("Game unfocused");
|
||||
|
||||
if (focusMusicTween != null)
|
||||
focusMusicTween.cancel();
|
||||
focusMusicTween = FlxTween.tween(FlxG.sound, {volume: newVol}, 0.5);
|
||||
|
||||
// Conserve power by lowering draw framerate when unfocuced
|
||||
FlxG.updateFramerate = 60;
|
||||
FlxG.drawFramerate = 60;
|
||||
}
|
||||
}
|
||||
|
||||
function onWindowFocusIn()
|
||||
{
|
||||
new FlxTimer().start(0.2, function(tmr:FlxTimer)
|
||||
{
|
||||
focused = true;
|
||||
});
|
||||
|
||||
// Lower global volume when unfocused
|
||||
if (Type.getClass(FlxG.state) != PlayState)
|
||||
{
|
||||
trace("Game focused");
|
||||
|
||||
// Normal global volume when focused
|
||||
if (focusMusicTween != null)
|
||||
focusMusicTween.cancel();
|
||||
|
||||
focusMusicTween = FlxTween.tween(FlxG.sound, {volume: oldVol}, 0.5);
|
||||
|
||||
// Bring framerate back when focused
|
||||
FlxG.drawFramerate = 144;
|
||||
FlxG.updateFramerate = 144;
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
// Code was entirely made by sqirra-rng for their fnf engine named "Izzy Engine", big props to them!!!
|
||||
// very cool person for real they don't get enough credit for their work
|
||||
#if ErrorDialog
|
||||
|
|
|
@ -58,6 +58,10 @@ using StringTools;
|
|||
import Discord.DiscordClient;
|
||||
#end
|
||||
|
||||
#if desktop
|
||||
import lime.app.Application;
|
||||
#end
|
||||
|
||||
class PlayState extends MusicBeatState
|
||||
{
|
||||
public static var curStage:String = '';
|
||||
|
@ -67,6 +71,7 @@ class PlayState extends MusicBeatState
|
|||
public static var storyPlaylist:Array<String> = [];
|
||||
public static var storyDifficulty:Int = 1;
|
||||
public static var deathCounter:Int = 0;
|
||||
public static var dead:Bool = false;
|
||||
public static var practiceMode:Bool = false;
|
||||
|
||||
var halloweenLevel:Bool = false;
|
||||
|
@ -185,7 +190,9 @@ class PlayState extends MusicBeatState
|
|||
|
||||
FlxG.sound.cache(Paths.inst(PlayState.SONG.song));
|
||||
FlxG.sound.cache(Paths.voices(PlayState.SONG.song));
|
||||
Application.current.window.onFocusOut.add(onWindowFocusOut);
|
||||
|
||||
dead = false;
|
||||
// var gameCam:FlxCamera = FlxG.camera;
|
||||
camGame = new SwagCamera();
|
||||
camHUD = new FlxCamera();
|
||||
|
@ -1921,6 +1928,7 @@ class PlayState extends MusicBeatState
|
|||
if (FlxG.keys.justPressed.SEVEN)
|
||||
{
|
||||
FlxG.switchState(new ChartingState());
|
||||
Application.current.window.onFocusOut.remove(onWindowFocusOut);
|
||||
|
||||
#if discord_rpc
|
||||
DiscordClient.changePresence("Chart Editor", null, null, true);
|
||||
|
@ -2050,6 +2058,7 @@ class PlayState extends MusicBeatState
|
|||
{
|
||||
// boyfriend.stunned = true;
|
||||
|
||||
dead = true;
|
||||
persistentUpdate = false;
|
||||
persistentDraw = false;
|
||||
paused = true;
|
||||
|
@ -2148,6 +2157,14 @@ class PlayState extends MusicBeatState
|
|||
var spr:StrumNote = null;
|
||||
spr = opponentStrums.members[daNote.noteData];
|
||||
spr.animation.play('confirm', true);
|
||||
if (!curStage.startsWith('school'))
|
||||
{
|
||||
spr.centerOffsets();
|
||||
spr.offset.x -= 13;
|
||||
spr.offset.y -= 13;
|
||||
}
|
||||
else
|
||||
spr.centerOffsets();
|
||||
spr.resetAnim = time;
|
||||
|
||||
if (SONG.song != 'Tutorial')
|
||||
|
@ -2269,6 +2286,7 @@ class PlayState extends MusicBeatState
|
|||
canPause = false;
|
||||
FlxG.sound.music.volume = 0;
|
||||
vocals.volume = 0;
|
||||
Application.current.window.onFocusOut.remove(onWindowFocusOut);
|
||||
if (SONG.validScore)
|
||||
{
|
||||
Highscore.saveScore(SONG.song, songScore, storyDifficulty);
|
||||
|
@ -3116,4 +3134,33 @@ class PlayState extends MusicBeatState
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onWindowFocusOut():Void
|
||||
{
|
||||
if (!dead && !paused && startedCountdown && canPause)
|
||||
{
|
||||
persistentUpdate = false;
|
||||
persistentDraw = true;
|
||||
paused = true;
|
||||
|
||||
// 1 / 1000 chance for Gitaroo Man easter egg
|
||||
if (FlxG.random.bool(0.1))
|
||||
{
|
||||
// gitaroo man easter egg
|
||||
FlxG.switchState(new GitarooPause());
|
||||
}
|
||||
else
|
||||
{
|
||||
var boyfriendPos = boyfriend.getScreenPosition();
|
||||
var pauseSubState = new PauseSubState(boyfriendPos.x, boyfriendPos.y);
|
||||
openSubState(pauseSubState);
|
||||
pauseSubState.camera = camHUD;
|
||||
boyfriendPos.put();
|
||||
}
|
||||
|
||||
#if discord_rpc
|
||||
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
|
||||
#end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue