Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
cheaper lerp calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Nov 8, 2023
1 parent 184105d commit 0f8c8e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 105 deletions.
2 changes: 1 addition & 1 deletion source/funkin/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class PlayState extends MusicBeatState {
}

public function startVideo(path:String, ?completeFunc:Dynamic):Void {
completeFunc = completeFunc == null ? startCountdown : completeFunc;
completeFunc = completeFunc ?? startCountdown;
#if cpp
var video:FlxVideo = new FlxVideo();
var vidFunc = function () {
Expand Down
44 changes: 22 additions & 22 deletions source/funkin/util/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class CoolUtil {
}

inline public static function playSound(key:String, volume:Float = 1, ?pitch:Float) {
var sound = getSound(key);
final sound = getSound(key);
sound.volume = volume;
sound.pitch = (pitch == null ? FlxG.timeScale : pitch);
sound.pitch = pitch ?? FlxG.timeScale;
sound.play();
return sound;
}
Expand Down Expand Up @@ -141,12 +141,13 @@ class CoolUtil {
FlxG.sound.music = null;
}

static final baseLerp = 1 / 60;
inline public static function getLerp(ratio:Float):Float {
return FlxG.elapsed / (1 / 60) * ratio;
return FlxG.elapsed / baseLerp * ratio;
}

inline public static function coolLerp(a:Float, b:Float, ratio:Float):Float {
return FlxMath.lerp(a,b,getLerp(ratio));
return FlxMath.lerp(a, b, getLerp(ratio));
}

public static function sortByStrumTime(a:Dynamic, b:Dynamic) {
Expand Down Expand Up @@ -177,9 +178,8 @@ class CoolUtil {
public static function removeDuplicates(input:Array<String>):Array<String> {
var result:Array<String> = [];
for (i in input) {
if (!result.contains(i)) {
if (!result.contains(i))
result.push(i);
}
}
return result;
}
Expand Down Expand Up @@ -214,6 +214,22 @@ class CoolUtil {
return FlxG.cameras.list[FlxG.cameras.list.length - 1];
}

inline public static function switchState(newState:FlxState) {
if (MusicBeatState.instance == null) {
FlxG.switchState(newState);
return;
}
MusicBeatState.instance.switchState(newState);
}

inline public static function resetState() {
if (MusicBeatState.instance == null) {
FlxG.resetState();
return;
}
MusicBeatState.instance.resetState();
}

/*
* RATING UTIL
*/
Expand Down Expand Up @@ -242,20 +258,4 @@ class CoolUtil {
inline public static function getNoteDiff(daNote:Note):Float {
return Math.abs(daNote.strumTime - Conductor.songPosition);
}

inline public static function switchState(newState:FlxState) {
if (MusicBeatState.instance == null) {
FlxG.switchState(newState);
return;
}
MusicBeatState.instance.switchState(newState);
}

inline public static function resetState() {
if (MusicBeatState.instance == null) {
FlxG.resetState();
return;
}
MusicBeatState.instance.resetState();
}
}
5 changes: 5 additions & 0 deletions source/funkin/util/backend/UnZipper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import haxe.zip.Uncompress;
import haxe.zip.Reader;
import sys.io.File;

/*
Credits to part of this code to the Yoshi Crafter engine devs!!
I was way too dumb to figure out haxe zip by myself!!
*/

class UnZipper {
public static function getZipEntries(path:String) {
var zipData = openZip(path);
Expand Down
82 changes: 0 additions & 82 deletions source/funkin/util/modding/PsychLuaConverter.hx

This file was deleted.

0 comments on commit 0f8c8e5

Please sign in to comment.