1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-09 16:24:42 +00:00
Funkin/source/CoolUtil.hx

85 lines
2 KiB
Haxe
Raw Normal View History

2021-01-15 04:33:12 +00:00
package;
import flixel.FlxG;
import flixel.graphics.FlxGraphic;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.math.FlxMath;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxGraphicAsset;
import haxe.Json;
import lime.math.Rectangle;
2021-01-15 04:33:12 +00:00
import lime.utils.Assets;
using StringTools;
class CoolUtil
{
2021-03-02 04:00:02 +00:00
public static var difficultyArray:Array<String> = ['EASY', "NORMAL", "HARD"];
public static function difficultyString():String
{
return difficultyArray[PlayState.storyDifficulty];
}
2021-01-15 04:33:12 +00:00
public static function coolTextFile(path:String):Array<String>
{
var daList:Array<String> = Assets.getText(path).trim().split('\n');
for (i in 0...daList.length)
{
daList[i] = daList[i].trim();
}
return daList;
}
2021-01-25 10:04:31 +00:00
public static function numberArray(max:Int, ?min = 0):Array<Int>
{
var dumbArray:Array<Int> = [];
for (i in min...max)
{
dumbArray.push(i);
}
return dumbArray;
}
2021-05-26 23:22:15 +00:00
static var oldCamPos:FlxPoint = new FlxPoint();
static var oldMousePos:FlxPoint = new FlxPoint();
public static function mouseCamDrag():Void
{
if (FlxG.mouse.justPressedMiddle)
{
oldCamPos.set(FlxG.camera.scroll.x, FlxG.camera.scroll.y);
oldMousePos.set(FlxG.mouse.screenX, FlxG.mouse.screenY);
}
if (FlxG.mouse.pressedMiddle)
{
FlxG.camera.scroll.x = oldCamPos.x - (FlxG.mouse.screenX - oldMousePos.x);
FlxG.camera.scroll.y = oldCamPos.y - (FlxG.mouse.screenY - oldMousePos.y);
}
}
2021-04-04 17:17:46 +00:00
/**
Lerps camera, but accountsfor framerate shit?
Right now it's simply for use to change the followLerp variable of a camera during update
TODO LATER MAYBE:
Actually make and modify the scroll and lerp shit in it's own function
instead of solely relying on changing the lerp on the fly
*/
public static function camLerpShit(lerp:Float):Float
{
return lerp * (FlxG.elapsed / (1 / 60));
}
/*
2021-05-26 23:22:15 +00:00
* frame dependant lerp kinda lol
*/
2021-05-15 21:39:13 +00:00
public static function coolLerp(base:Float, target:Float, ratio:Float):Float
{
2021-05-15 21:39:13 +00:00
return base + camLerpShit(ratio) * (target - base);
}
2021-05-26 23:22:15 +00:00
}