Skip to content

Commit

Permalink
fix bugs and hopefuilly some performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Aug 22, 2024
1 parent def2c17 commit a2440cf
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 304 deletions.
5 changes: 3 additions & 2 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@
<haxedef name="HXCPP_STACK_LINE" if="release" />
<haxedef name="HXCPP_STACK_TRACE" if="release" />

<haxedef name="HXCPP_GC_BIG_BLOCKS" />
<haxedef name="no-debug" unless="debug" />
<haxedef name="HXCPP_GC_GENERATIONAL" />

<icon path="art/icon.png" />
</project>
</project>
1 change: 1 addition & 0 deletions build/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ haxelib git fnf-modcharting-tools https://github.com/Vortex2Oblivion/FNF-Modchar
haxelib git flxanimate https://github.com/funkincrew/flxanimate
haxelib git hxNoise https://github.com/whuop/hxNoise
haxelib git funkin.vis https://github.com/FNF-CNE-Devs/funkVis grig-test
haxelib git hxcpp https://github.com/HaxeFoundation/hxcpp
haxelib install hxcpp-debug-server
```

Expand Down
4 changes: 0 additions & 4 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class Main extends Sprite {
CoolUtil.haxe_trace = Log.trace;
Log.trace = CoolUtil.haxe_print;

#if VIDEOS_ALLOWED
hxvlc.util.Handle.init();
#end

game = new FlxGame(0, 0, TitleState, 60, 60, true);

// FlxG.game._customSoundTray wants just the class, it calls new from
Expand Down
42 changes: 20 additions & 22 deletions source/game/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import flixel.FlxG;
import flixel.FlxSprite;
import flixel.addons.effects.FlxSkewedSprite;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.math.FlxMath;

using StringTools;

Expand Down Expand Up @@ -157,26 +158,23 @@ class Note extends FlxSkewedSprite {
animation.play("default");

if (!PlayState.instance.arrow_Configs.exists(arrow_Type)) {
if (PlayState.instance.types.contains(arrow_Type)){
if(Assets.exists(Paths.txt("ui skins/" + song.ui_Skin + "/" + arrow_Type))){
if (PlayState.instance.types.contains(arrow_Type)) {
if (Assets.exists(Paths.txt("ui skins/" + song.ui_Skin + "/" + arrow_Type))) {
PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/" + song.ui_Skin + "/" + arrow_Type)));
}
else{
} else {
PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/" + song.ui_Skin + "/default")));
}
}
else{
if(Assets.exists(Paths.txt("ui skins/default/" + arrow_Type))){
} else {
if (Assets.exists(Paths.txt("ui skins/default/" + arrow_Type))) {
PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/default/" + arrow_Type)));
}
else{
} else {
PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/default/default")));
}
}

PlayState.instance.type_Configs.set(arrow_Type, Assets.exists(Paths.txt("arrow types/" + arrow_Type)) ?
CoolUtil.coolTextFile(Paths.txt("arrow types/" + arrow_Type)) :
CoolUtil.coolTextFile(Paths.txt("arrow types/default")));
PlayState.instance.type_Configs.set(arrow_Type,
Assets.exists(Paths.txt("arrow types/" + arrow_Type)) ? CoolUtil.coolTextFile(Paths.txt("arrow types/" +
arrow_Type)) : CoolUtil.coolTextFile(Paths.txt("arrow types/default")));
PlayState.instance.setupNoteTypeScript(arrow_Type);
}

Expand Down Expand Up @@ -207,18 +205,9 @@ class Note extends FlxSkewedSprite {
prevNoteStrumtime = prevNote.strumTime;
prevNoteIsSustainNote = prevNote.isSustainNote;

if (!song.ui_Skin.contains("pixel"))
x += width / 2;

animation.play("holdend");
updateHitbox();

if (!song.ui_Skin.contains("pixel"))
x -= width / 2;

if (song.ui_Skin.contains("pixel"))
x += 30;

if (prevNote.isSustainNote) {
if (prevNote.animation != null)
prevNote.animation.play("hold");
Expand Down Expand Up @@ -256,6 +245,16 @@ class Note extends FlxSkewedSprite {
}
}

/**
* Calculates the Y value of a note.
* @param note the note to calculate
* @return The Y value. NOTE: Will return the negative value if downscroll is enabled.
*/
public static function calculateY(note:Note):Float {
return (Options.getData("downscroll") ? 1 : -1) * (0.45 * (Conductor.songPosition - note.strumTime) * FlxMath.roundDecimal(PlayState.instance.speed,
2));
}

override function update(elapsed:Float) {
super.update(elapsed);

Expand Down Expand Up @@ -301,7 +300,6 @@ class Note extends FlxSkewedSprite {
}
}
}

}

typedef NoteType = {
Expand Down
52 changes: 18 additions & 34 deletions source/game/StrumNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import states.PlayState;
import flixel.FlxSprite;
import flixel.addons.effects.FlxSkewedSprite;


using StringTools;

/*
credit to psych engine devs (sorry idk who made this originally, all ik is that srperez modified it for shaggy and then i got it from there)
*/
class StrumNote extends FlxSkewedSprite
{
class StrumNote extends FlxSkewedSprite {
public var resetAnim:Float = 0;

private var noteData:Int = 0;
Expand All @@ -31,18 +29,16 @@ class StrumNote extends FlxSkewedSprite
public var keyCount:Int;

public var colorSwap:ColorSwap = new ColorSwap();
public var noteColor:Array<Int> = [255,0,0];
public var noteColor:Array<Int> = [255, 0, 0];
public var affectedbycolor:Bool = false;

public var isPlayer:Float;

public var jsonData:JsonData;

public var modAngle:Float = 0;


public function new(x:Float, y:Float, leData:Int, ?ui_Skin:String, ?ui_settings:Array<String>, ?mania_size:Array<String>, ?keyCount:Int, ?isPlayer:Float)
{
public function new(x:Float, y:Float, leData:Int, ?ui_Skin:String, ?ui_settings:Array<String>, ?mania_size:Array<String>, ?keyCount:Int, ?isPlayer:Float) {
if (ui_Skin == null)
ui_Skin = PlayState.SONG.ui_Skin;

Expand All @@ -63,8 +59,8 @@ class StrumNote extends FlxSkewedSprite
this.keyCount = keyCount;
this.isPlayer = isPlayer;

if(Assets.exists(Paths.json("ui skins/" + ui_Skin + "/config"))){
jsonData = Json.parse(Assets.getText(Paths.json("ui skins/" + ui_Skin + "/config")));
if (Assets.exists(Paths.json("ui skins/" + ui_Skin + "/config"))) {
jsonData = Json.parse(Assets.getText(Paths.json("ui skins/" + ui_Skin + "/config")));
for (value in jsonData.values) {
this.affectedbycolor = value.affectedbycolor;
}
Expand All @@ -74,24 +70,21 @@ class StrumNote extends FlxSkewedSprite
noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData]);
shader = affectedbycolor ? colorSwap.shader : null;

if(affectedbycolor && PlayState.instance != null && colorSwap != null){
if (noteColor != null){
if (affectedbycolor && PlayState.instance != null && colorSwap != null) {
if (noteColor != null) {
colorSwap.r = noteColor[0];
colorSwap.g = noteColor[1];
colorSwap.b = noteColor[2];
}
}
}

override function update(elapsed:Float)
{
override function update(elapsed:Float) {
angle = modAngle;
if (resetAnim > 0)
{
if (resetAnim > 0) {
resetAnim -= elapsed;

if (resetAnim <= 0)
{
if (resetAnim <= 0) {
playAnim('static');
resetAnim = 0;
}
Expand All @@ -100,38 +93,29 @@ class StrumNote extends FlxSkewedSprite
super.update(elapsed);
}

public function playAnim(anim:String, ?force:Bool = false)
{
public function playAnim(anim:String, ?force:Bool = false) {
animation.play(anim, force);
// updateHitbox();
centerOrigin();

if (anim == "static")
{
if (anim == "static") {
colorSwap.r = 255;
colorSwap.g = 0;
colorSwap.b = 0;

swagWidth = width;
}
else
{
} else {
colorSwap.r = noteColor[0];
colorSwap.g = noteColor[1];
colorSwap.b = noteColor[2];
}

if (!ui_Skin.contains("pixel"))
{
offset.x = frameWidth / 2;
offset.y = frameHeight / 2;
offset.x = frameWidth / 2;
offset.y = frameHeight / 2;

var scale:Float = Std.parseFloat(ui_settings[0]) * (Std.parseFloat(ui_settings[2]) - (Std.parseFloat(mania_size[keyCount - 1])));
var scale:Float = Std.parseFloat(ui_settings[0]) * (Std.parseFloat(ui_settings[2]) - (Std.parseFloat(mania_size[keyCount - 1])));

offset.x -= 156 * scale / 2;
offset.y -= 156 * scale / 2;
}
else
centerOffsets();
offset.x -= 156 * scale / 2;
offset.y -= 156 * scale / 2;
}
}
Loading

0 comments on commit a2440cf

Please sign in to comment.