Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryiuu04 committed Jul 14, 2024
1 parent 8ddce03 commit a6a0165
Show file tree
Hide file tree
Showing 54 changed files with 1,008 additions and 226 deletions.
2 changes: 2 additions & 0 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

<classpath name="source" />

<assets path="assets/shared/images" />

<assets path="assets/preload" rename="assets" exclude="*.ogg" if="web"/>
<assets path="assets/preload" rename="assets" exclude="*.mp3" unless="web"/>

Expand Down
Binary file added assets/fonts/phantomMuff.ttf
Binary file not shown.
Binary file modified assets/preload/images/FNF_main_menu_assets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
167 changes: 90 additions & 77 deletions assets/preload/images/FNF_main_menu_assets.xml

Large diffs are not rendered by default.

Binary file modified assets/preload/images/num1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/bars_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preload/images/soundtray/volumebox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
Binary file added assets/preload/music/tea-time.ogg
Binary file not shown.
Binary file added assets/preload/sounds/soundtray/VolMAX.ogg
Binary file not shown.
Binary file added assets/preload/sounds/soundtray/Voldown.ogg
Binary file not shown.
Binary file added assets/preload/sounds/soundtray/Volup.ogg
Binary file not shown.
Binary file added assets/shared/images/credits/bb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/blantad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/evilsk8r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/flicky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/kade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/kawaisprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/mastereric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/ninjamuffin99.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/phantomarcade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/riveren.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/rozebud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/ryv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/credits/shadowmario.png
11 changes: 9 additions & 2 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import flixel.FlxState;
import openfl.Assets;
import openfl.Lib;
import openfl.display.FPS;
import debug.FPSCounter;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.display.StageScaleMode;
Expand Down Expand Up @@ -101,10 +102,16 @@ class Main extends Sprite

game = new FlxGame(gameWidth, gameHeight, initialState, #if (flixel < "5.0.0") zoom, #end framerate, framerate, skipSplash, startFullscreen);

// FlxG.game._customSoundTray wants just the class, it calls new from
// create() in there, which gets called when it's added to stage
// which is why it needs to be added before addChild(game) here
@:privateAccess
game._customSoundTray = options.FunkinSoundTray;

addChild(game);

#if !mobile
fpsCounter = new FPS(10, 3, 0xFFFFFF);
fpsCounter = new FPSCounter(3, 3, 0xFFFFFF);
addChild(fpsCounter);
Lib.current.stage.align = "tl";
Lib.current.stage.scaleMode = StageScaleMode.NO_SCALE;
Expand Down Expand Up @@ -156,7 +163,7 @@ class Main extends Sprite

var game:FlxGame;

public static var fpsCounter:FPS;
public static var fpsCounter:FPSCounter;

public function toggleFPS(fpsEnabled:Bool):Void {
fpsCounter.visible = fpsEnabled;
Expand Down
9 changes: 7 additions & 2 deletions source/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import states.TitleState;
public var violence:Bool = true;
public var stageChange:Bool = true;
public var uncacheCharacterSwitch:Bool = false;
public var showNextSection:Bool = false;
public var showNextSection:Bool = true;

public var botplay:Bool = false;
public var songPosition:Bool = false;
Expand Down Expand Up @@ -143,6 +143,7 @@ class ClientPrefs {
FlxG.save.data.fps = data.showFPS;
FlxG.save.data.showFPS = data.showFPS;
FlxG.save.data.noteSplash = data.noteSplashes;
data.fpsCap = data.framerate;
FlxG.save.data.fpsCap = data.framerate;
FlxG.save.data.ghost = data.ghostTapping;

Expand Down Expand Up @@ -173,8 +174,12 @@ class ClientPrefs {

if(FlxG.save.data.fpsCap != null) {
var framerate = data.framerate;
framerate = FlxG.save.data.framerate;

framerate = FlxG.save.data.fpsCap;
openfl.Lib.current.stage.frameRate = framerate;
Main.curFPS = framerate;

FlxG.save.data.fpsCap = framerate;
if(framerate > FlxG.drawFramerate) {
FlxG.updateFramerate = framerate;
FlxG.drawFramerate = framerate;
Expand Down
131 changes: 131 additions & 0 deletions source/backend/MathUtils.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package backend;

/**
* Utilities for performing mathematical operations.
*/
class MathUtils
{
/**
* Euler's constant and the base of the natural logarithm.
* Math.E is not a constant in Haxe, so we'll just define it ourselves.
*/
public static final E:Float = 2.71828182845904523536;

/**
* Perform linear interpolation between the base and the target, based on the current framerate.
* @param base The starting value, when `progress <= 0`.
* @param target The ending value, when `progress >= 1`.
* @param ratio Value used to interpolate between `base` and `target`.
*
* @return The interpolated value.
*/
@:deprecated('Use smoothLerp instead')
public static function coolLerp(base:Float, target:Float, ratio:Float):Float
{
return base + cameraLerp(ratio) * (target - base);
}

/**
* Perform linear interpolation based on the current framerate.
* @param lerp Value used to interpolate between `base` and `target`.
*
* @return The interpolated value.
*/
@:deprecated('Use smoothLerp instead')
public static function cameraLerp(lerp:Float):Float
{
return lerp * (FlxG.elapsed / (1 / 60));
}

/**
* Get the logarithm of a value with a given base.
* @param base The base of the logarithm.
* @param value The value to get the logarithm of.
* @return `log_base(value)`
*/
public static function logBase(base:Float, value:Float):Float
{
return Math.log(value) / Math.log(base);
}

public static function easeInOutCirc(x:Float):Float
{
if (x <= 0.0) return 0.0;
if (x >= 1.0) return 1.0;
var result:Float = (x < 0.5) ? (1 - Math.sqrt(1 - 4 * x * x)) / 2 : (Math.sqrt(1 - 4 * (1 - x) * (1 - x)) + 1) / 2;
return (result == Math.NaN) ? 1.0 : result;
}

public static function easeInOutBack(x:Float, ?c:Float = 1.70158):Float
{
if (x <= 0.0) return 0.0;
if (x >= 1.0) return 1.0;
var result:Float = (x < 0.5) ? (2 * x * x * ((c + 1) * 2 * x - c)) / 2 : (1 - 2 * (1 - x) * (1 - x) * ((c + 1) * 2 * (1 - x) - c)) / 2;
return (result == Math.NaN) ? 1.0 : result;
}

public static function easeInBack(x:Float, ?c:Float = 1.70158):Float
{
if (x <= 0.0) return 0.0;
if (x >= 1.0) return 1.0;
return (1 + c) * x * x * x - c * x * x;
}

public static function easeOutBack(x:Float, ?c:Float = 1.70158):Float
{
if (x <= 0.0) return 0.0;
if (x >= 1.0) return 1.0;
return 1 + (c + 1) * Math.pow(x - 1, 3) + c * Math.pow(x - 1, 2);
}

/**
* Get the base-2 logarithm of a value.
* @param x value
* @return `2^x`
*/
public static function exp2(x:Float):Float
{
return Math.pow(2, x);
}

/**
* Linearly interpolate between two values.
*
* @param base The starting value, when `progress <= 0`.
* @param target The ending value, when `progress >= 1`.
* @param progress Value used to interpolate between `base` and `target`.
* @return The interpolated value.
*/
public static function lerp(base:Float, target:Float, progress:Float):Float
{
return base + progress * (target - base);
}

/**
* Perform a framerate-independent linear interpolation between the base value and the target.
* @param current The current value.
* @param target The target value.
* @param elapsed The time elapsed since the last frame.
* @param duration The total duration of the interpolation. Nominal duration until remaining distance is less than `precision`.
* @param precision The target precision of the interpolation. Defaults to 1% of distance remaining.
* @see https://twitter.com/FreyaHolmer/status/1757918211679650262
*
* @return A value between the current value and the target value.
*/
public static function smoothLerp(current:Float, target:Float, elapsed:Float, duration:Float, precision:Float = 1 / 100):Float
{
// An alternative algorithm which uses a separate half-life value:
// var halfLife:Float = -duration / logBase(2, precision);
// lerp(current, target, 1 - exp2(-elapsed / halfLife));

if (current == target) return target;

var result:Float = lerp(current, target, 1 - Math.pow(precision, elapsed / duration));

// TODO: Is there a better way to ensure a lerp which actually reaches the target?
// Research a framerate-independent PID lerp.
if (Math.abs(result - target) < (precision * target)) result = target;

return result;
}
}
76 changes: 76 additions & 0 deletions source/debug/FPSCounter.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package debug;

import flixel.FlxG;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.system.System;
import openfl.utils.Assets;

/**
The FPS class provides an easy-to-use monitor to display
the current frame rate of an OpenFL project
**/
class FPSCounter extends TextField
{
/**
The current frame rate, expressed using frames-per-second
**/
public var currentFPS(default, null):Int;

/**
The current memory usage (WARNING: this is NOT your total program memory usage, rather it shows the garbage collector memory)
**/
public var memoryMegas(get, never):Float;

@:noCompletion private var times:Array<Float>;

public function new(x:Float = 10, y:Float = 10, color:Int = 0x000000)
{
super();

this.x = x;
this.y = y;

currentFPS = 0;
selectable = false;
mouseEnabled = false;
defaultTextFormat = new TextFormat("_sans", 12, color);
autoSize = LEFT;
multiline = true;
text = "FPS: ";

times = [];
}

var deltaTimeout:Float = 0.0;

// Event Handlers
private override function __enterFrame(deltaTime:Float):Void
{
// prevents the overlay from updating every frame, why would you need to anyways
if (deltaTimeout > 1000) {
deltaTimeout = 0.0;
return;
}

final now:Float = haxe.Timer.stamp() * 1000;
times.push(now);
while (times[0] < now - 1000) times.shift();

currentFPS = times.length < FlxG.drawFramerate ? times.length : FlxG.drawFramerate;
updateText();
deltaTimeout += deltaTime;
}

public dynamic function updateText():Void { // so people can override it in hscript
text = 'FPS: ${currentFPS}'
+ ' | Memory: ${flixel.util.FlxStringUtil.formatBytes(memoryMegas)}';

textColor = 0xFFFFFFFF;
if (currentFPS < FlxG.drawFramerate * 0.5)
textColor = 0xFFFF0000;
}

inline function get_memoryMegas():Float
return cast(System.totalMemory, UInt);
}
32 changes: 32 additions & 0 deletions source/luafiles/TweenFunctions.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package luafiles;

import luafiles.LuaUtils.LuaTweenOptions;
import objects.StrumNote;

class TweenFunctions
Expand All @@ -25,6 +26,37 @@ class TweenFunctions
oldTweenFunction(tag, vars, {zoom: value}, duration, ease, 'doTweenZoom');
});


Lua_helper.add_callback(lua, "startTween", function(tag:String, vars:String, values:Any = null, duration:Float, options:Any = null) {
var penisExam:Dynamic = LuaUtils.tweenPrepare(tag, vars);
if(penisExam != null) {
if(values != null) {
var myOptions:LuaTweenOptions = LuaUtils.getLuaTween(options);
game.modchartTweens.set(tag, FlxTween.tween(penisExam, values, duration, {
type: myOptions.type,
ease: myOptions.ease,
startDelay: myOptions.startDelay,
loopDelay: myOptions.loopDelay,

onUpdate: function(twn:FlxTween) {
if(myOptions.onUpdate != null) game.callOnLuas(myOptions.onUpdate, [tag, vars]);
},
onStart: function(twn:FlxTween) {
if(myOptions.onStart != null) game.callOnLuas(myOptions.onStart, [tag, vars]);
},
onComplete: function(twn:FlxTween) {
if(myOptions.onComplete != null) game.callOnLuas(myOptions.onComplete, [tag, vars]);
if(twn.type == FlxTweenType.ONESHOT || twn.type == FlxTweenType.BACKWARD) game.modchartTweens.remove(tag);
}
}));
} else {
ModchartState.luaTrace('startTween: No values on 2nd argument!', false, false, FlxColor.RED);
}
} else {
ModchartState.luaTrace('startTween: Couldnt find object: ' + vars, false, false, FlxColor.RED);
}
});

Lua_helper.add_callback(lua, "cancelTween", function(tag:String) {
LuaUtils.cancelTween(tag);
});
Expand Down
10 changes: 8 additions & 2 deletions source/objects/AttachedSprite.hx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package;
package objects;

import flixel.FlxSprite;
import flixel.FlxG;
Expand All @@ -25,7 +25,13 @@ class AttachedSprite extends FlxSprite
animation.addByPrefix('idle', anim, 24, loop);
animation.play('idle');
} else if(file != null) {
loadGraphic(Paths.image(file));
if(FileSystem.exists(Paths.getSharedPath('images/$file.png'))){//shared check...
loadGraphic(Paths.getSharedPath('images/$file.png'));//shared check...
//trace(Paths.getSharedPath('images/$file.png'));
}else{
loadGraphic(Paths.image(file));
//trace(Paths.image(file));
}
}
antialiasing = FlxG.save.data.antialiasing;
scrollFactor.set();
Expand Down
15 changes: 15 additions & 0 deletions source/objects/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef CharacterFile = {
var flip_x:Bool;
var no_antialiasing:Bool;
var healthbar_colors:Array<Int>;
var vocals_file:String;
var noteSkin:String;
var isPlayerChar:Bool;

Expand Down Expand Up @@ -103,6 +104,7 @@ class Character extends FunkinSprite
public var noAntialiasing:Bool = false;
public var originalFlipX:Bool = false;
public var healthColorArray:Array<Int> = [255, 0, 0];
public var vocalsFile:String = '';
public var positionArray:Array<Float> = [0, 0];
public var playerPositionArray:Array<Float> = [0, 0];
public var cameraPosition:Array<Float> = [0, 0];
Expand Down Expand Up @@ -278,6 +280,7 @@ class Character extends FunkinSprite
healthColorArray = json.healthbar_colors;
}

vocalsFile = json.vocals_file != null ? json.vocals_file : '';
colorPreString = FlxColor.fromRGB(healthColorArray[0], healthColorArray[1], healthColorArray[2]);
colorPreCut = colorPreString.toHexString();
iconColor = colorPreCut.substring(2);
Expand Down Expand Up @@ -724,4 +727,16 @@ class Character extends FunkinSprite
curColor = Color;
return super.set_color(Color);
}

public override function destroy()
{
super.destroy();
destroyAtlas();
}

public function destroyAtlas()
{
if (atlasChar != null)
atlasChar = FlxDestroyUtil.destroy(atlasChar);
}
}
1 change: 1 addition & 0 deletions source/objects/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class HealthIcon extends FlxSprite

animation.add(char, animArray, 0, false, isPlayer);
animation.play(char);
this.char = char;//silly icon name fix, idk if this will break something but i can remove later if does
}

public function swapOldIcon(char:String)
Expand Down
Loading

0 comments on commit a6a0165

Please sign in to comment.