Skip to content

Commit

Permalink
Optimizations and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
superpowers04 committed Jan 10, 2025
1 parent 7230552 commit 5249807
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 121 deletions.
8 changes: 1 addition & 7 deletions source/Alphabet.hx
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,7 @@ class Alphabet extends FlxSpriteGroup
if(SESave.data.useFontEverywhere){
Frames = new flixel.graphics.frames.FlxFramesCollection(FlxGraphic.fromRectangle(1,1,0x01000000,false,"blank.mp4"));
}else{
try{
if(!SELoader.exists("mods/alphabet.png") || !SELoader.exists("mods/alphabet.xml")) throw('');
Frames = SELoader.loadSparrowFrames('mods/alphabet');
}catch(e){
Frames = SELoader.loadSparrowFrames('assets/images/alphabet');
// Paths.getSparrowAtlas('alphabet');
}
Frames = SELoader.loadSparrowFrames((SELoader.exists("mods/alphabet.png") && SELoader.exists("mods/alphabet.xml")) ? 'mods/alphabet' : 'assets/images/alphabet');
}
}
this.text = text;
Expand Down
10 changes: 9 additions & 1 deletion source/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ class Conductor {
public static var bpmChangeMapSteps:Map<Int,BPMChangeEvent> = [];

public function new(){}
public static var lastFrameTime:Float = 0;
public static function update(){
songPosition = FlxG.sound.music.time;
inline updateElapsed(FlxG.elapsed);
}
public static function updateElapsed(elapsed:Float){
if(lastFrameTime == FlxG.sound.music.time){
songPosition += elapsed * 1000;
}else{
lastFrameTime = songPosition = FlxG.sound.music.time;
}
}

@:keep inline public static function recalculateTimings() {
Expand Down
2 changes: 1 addition & 1 deletion source/FinishSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package;

import openfl.Lib;

import Controls.Control;
// import Controls.Control;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxSubState;
Expand Down
2 changes: 1 addition & 1 deletion source/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class ScrollSpeedOption extends HCFloatOption{
}
override public function draw(){
if(note == null || strum == null) return;
var dist = (Conductor.songPosition - note.strumTime);
var dist = ((Conductor.songPosition+FlxG.elapsed*0.001) - note.strumTime);
var _scrollSpeed = SESave.data.scrollSpeed;
Conductor.update();
if(dist > 1000 || pressed){
Expand Down
7 changes: 3 additions & 4 deletions source/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class PauseSubState extends MusicBeatSubstate {
ease: FlxEase.cubeInOut,
// onComplete: function(twn:FlxTween) {ready.destroy();}
});
FlxG.sound.play(Paths.sound('intro2' + altSuffix), 0.6);
SELoader.playSound('assets/sounds/intro2' + altSuffix,0.6);
case 2:
var set:FlxSprite = spr.loadGraphic(Paths.image(introAlts[1]));
tween.cancel();
Expand All @@ -495,7 +495,7 @@ class PauseSubState extends MusicBeatSubstate {
ease: FlxEase.cubeInOut,
// onComplete: function(twn:FlxTween) {set.destroy();}
});
FlxG.sound.play(Paths.sound('intro1' + altSuffix), 0.6);
SELoader.playSound('assets/sounds/intro1' + altSuffix,0.6);
case 3:
var go:FlxSprite = spr.loadGraphic(Paths.image(introAlts[2]));
tween.cancel();
Expand All @@ -509,9 +509,8 @@ class PauseSubState extends MusicBeatSubstate {
ease: FlxEase.cubeInOut,
onComplete: function(twn:FlxTween) {go.destroy();}
});
FlxG.sound.play(Paths.sound('introGo' + altSuffix), 0.6);
SELoader.playSound('assets/sounds/introGo' + altSuffix,0.6);
case 4:

backToPlaystate();

}
Expand Down
82 changes: 22 additions & 60 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class PlayState extends ScriptMusicBeatState
isFunc:true,
value:value,
check:type,
variable:(if(variable == "def") (if(check == 0) "curBeat" else "curStep") else variable),
variable:((variable == "def") ? ((check == 0) ? "curBeat" : "curStep") : variable),
func:func,
type:type
};
Expand Down Expand Up @@ -732,7 +732,6 @@ class PlayState extends ScriptMusicBeatState
}

//dialogue shit
loadDialog();
LoadingScreen.loadingText = "Loading stage";
// Stage management
var bfPos:Array<Float> = [0,0];
Expand Down Expand Up @@ -861,9 +860,6 @@ class PlayState extends ScriptMusicBeatState
}

if(loadChars && (SESave.data.gfShow || _dadShow || SESave.data.bfShow)){



LoadingScreen.loadingText = "Loading GF";
if(gf== null || !SESave.data.persistGF || (!SESave.data.gfShow && !Std.isOfType(gf,EmptyCharacter)) || gf.getNamespacedName() != player2){
if (SESave.data.gfShow && gfShow)
Expand Down Expand Up @@ -1164,33 +1160,6 @@ class PlayState extends ScriptMusicBeatState
}
#end
}
function loadDialog(){
// dialogue = [];
// switch (SONG.song.toLowerCase())
// {
// case 'tutorial':
// dialogue = CoolUtil.coolFormat("4*");
// case 'bopeebo':
// dialogue = CoolUtil.coolFormat(
// 'dad:HEY!\n' +
// 'bf:Beep?\n' +
// "dad:You think you can just sing\\nwith my daughter like that?\n" +
// 'bf:Beep' +
// "dad:If you want to date her...\\n" +
// "dad:You're going to have to go \\nthrough ME first!\n" +
// 'bf:Beep bop!'
// );
// case 'fresh':
// dialogue = CoolUtil.coolFormat("dad:Not too shabby $BF.\ndad:But I'd like to see you\\n keep up with this!");
// case 'dad battle':
// dialogue = CoolUtil.coolFormat(
// "dad:Gah, you think you're hot stuff?\n"+
// "dad:If you can beat me here...\n"+
// "dad:Only then I will even CONSIDER letting you\\ndate my daughter!"+
// 'bf:Beep!'
// );
// }
}



Expand Down Expand Up @@ -1279,7 +1248,6 @@ class PlayState extends ScriptMusicBeatState
}
}
if(underlay != null && SESave.data.undlaSize == 0){

underlay.x = playerStrums.members[0].x -2;
}
}
Expand All @@ -1289,10 +1257,7 @@ class PlayState extends ScriptMusicBeatState
public static var introAudio:Array<Dynamic> = [];
public static var introGraphics:Array<flixel.system.FlxAssets.FlxGraphicAsset> = [];
public function startCountdown():Void{

dialogue = [];


inCutscene = false;

if(!songStarted){
Expand All @@ -1306,13 +1271,11 @@ class PlayState extends ScriptMusicBeatState
playerStrums.visible = cpuStrums.visible = true;
FlxG.camera.zoom = FlxMath.lerp(0.90, FlxG.camera.zoom, 0.95);
camHUD.zoom = FlxMath.lerp(1, camHUD.zoom, 0.95);
// camFollow.setPosition(720, 500);



startedCountdown = true;
Conductor.songPosition = (introAudio.length + 1) * -500;
// Conductor.changeBPM(2);


if(errorMsg != "") {
Expand Down Expand Up @@ -1381,7 +1344,6 @@ class PlayState extends ScriptMusicBeatState
}catch(e){
showTempmessage('Unable to play ${sound} at $swagCounter',0xFFFF0000);
}

}
}
}
Expand Down Expand Up @@ -2121,11 +2083,11 @@ class PlayState extends ScriptMusicBeatState

if(iconP1.isTracked){
iconP1.trackingOffset = -26;
iconP1.updateTracking(if(healthBar.fillDirection == LEFT_TO_RIGHT) health * 0.5 else 1 - (health * 0.5));
iconP1.updateTracking((healthBar.fillDirection == LEFT_TO_RIGHT) ? health * 0.5 : 1 - (health * 0.5));
}
if(iconP2.isTracked){
iconP2.trackingOffset = -(iconP2.width - 26);
iconP2.updateTracking(if(healthBar.fillDirection == LEFT_TO_RIGHT) health * 0.5 else 1 - (health * 0.5));
iconP2.updateTracking((healthBar.fillDirection == LEFT_TO_RIGHT) ? health * 0.5 : 1 - (health * 0.5));
}

// else{
Expand Down Expand Up @@ -2153,13 +2115,7 @@ class PlayState extends ScriptMusicBeatState
}else{
if(FlxG.sound.music != null){
recalcSpeed();

if(FlxG.sound.music.time == lastFrameTime){
Conductor.songPosition += elapsed * 1000 * speed;
}else{
Conductor.songPosition = FlxG.sound.music.time;
}
lastFrameTime = FlxG.sound.music.time;
inline Conductor.updateElapsed(elapsed*speed);
if(Conductor.songPosition > FlxG.sound.music.length - 100 && !endingSong && FlxG.sound.music.onComplete != null){
var complete = FlxG.sound.music.onComplete;
FlxG.sound.music.onComplete = null;
Expand Down Expand Up @@ -3403,7 +3359,7 @@ class PlayState extends ScriptMusicBeatState
callInterp("noteMiss",[player,daNote,direction,calcStats]);
player.callInterp('noteMiss',[daNote,direction,calcStats]);
}
onlineNoteHit(if(daNote == null) -1 else daNote.noteID,direction + 1);
onlineNoteHit((daNote == null) ? -1 : daNote.noteID,direction + 1);



Expand Down Expand Up @@ -3497,22 +3453,28 @@ class PlayState extends ScriptMusicBeatState

restartTimes++;

bf.currentAnimationPriority = -10;
dad.currentAnimationPriority = -10;
gf.currentAnimationPriority = -10;
if(bf != null) bf.dance();
if(dad != null) dad.dance();
if(gf != null) gf.dance();



if(bf != null) {
bf.currentAnimationPriority = -10;
bf.dance();
}
if(dad != null) {
dad.currentAnimationPriority = -10;
dad.dance();
}
if(gf != null) {
gf.currentAnimationPriority = -10;
gf.dance();
}
health=1;

Conductor.songPosition = -5000;
vocals.time = FlxG.sound.music.time = 0;
vocals.volume = SESave.data.voicesVol;
startingSong=true;
songStarted = false;
startedCountdown = false;
handleHealth=true;
finished=false;
songStarted = startedCountdown = finished=false;
startingSong = handleHealth = true;
for (i=>v in notes.members){
if(v == null) continue;
v.acceleration.y = FlxG.random.int(200, 300);
Expand Down
Loading

0 comments on commit 5249807

Please sign in to comment.