Skip to content

Commit

Permalink
fix the sutter at the start of the song
Browse files Browse the repository at this point in the history
  • Loading branch information
Kade-github committed Aug 8, 2021
1 parent b166733 commit 8d6e9d8
Showing 1 changed file with 61 additions and 57 deletions.
118 changes: 61 additions & 57 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1695,65 +1695,9 @@ class PlayState extends MusicBeatState
previousFrameTime = FlxG.game.ticks;
lastReportedPlayheadPosition = 0;

if (!paused)
{
#if sys
if (!isStoryMode && isSM)
{
trace("Loading " + pathToSm + "/" + sm.header.MUSIC);
var bytes = File.getBytes(pathToSm + "/" + sm.header.MUSIC);
var sound = new Sound();
sound.loadCompressedDataFromByteArray(bytes.getData(), bytes.length);
FlxG.sound.playMusic(sound);
}
else
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
#else
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
#end
}

FlxG.sound.music.onComplete = endSong;
FlxG.sound.music.play();
vocals.play();

// Song duration in a float, useful for the time left feature
songLength = FlxG.sound.music.length;

if (FlxG.save.data.songPosition)
{
remove(songPosBG);
remove(songPosBar);
remove(songName);

songPosBG = new FlxSprite(0, 10).loadGraphic(Paths.image('healthBar'));
if (PlayStateChangeables.useDownscroll)
songPosBG.y = FlxG.height * 0.9 + 45;
songPosBG.screenCenter(X);
songPosBG.scrollFactor.set();
add(songPosBG);

songPosBar = new FlxBar(songPosBG.x
+ 4, songPosBG.y
+ 4, LEFT_TO_RIGHT, Std.int(songPosBG.width - 8), Std.int(songPosBG.height - 8), this,
'songPositionBar', 0, songLength
- 1000);
songPosBar.numDivisions = 1000;
songPosBar.scrollFactor.set();
songPosBar.createFilledBar(FlxColor.GRAY, FlxColor.LIME);
add(songPosBar);

var songName = new FlxText(songPosBG.x + (songPosBG.width / 2) - (SONG.song.length * 5), songPosBG.y, 0, SONG.song, 16);
if (PlayStateChangeables.useDownscroll)
songName.y -= 3;
songName.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
songName.scrollFactor.set();
add(songName);

songPosBG.cameras = [camHUD];
songPosBar.cameras = [camHUD];
songName.cameras = [camHUD];
}

// Song check real quick
switch (curSong)
{
Expand Down Expand Up @@ -1820,6 +1764,66 @@ class PlayState extends MusicBeatState

FlxG.sound.list.add(vocals);

if (!paused)
{
#if sys
if (!isStoryMode && isSM)
{
trace("Loading " + pathToSm + "/" + sm.header.MUSIC);
var bytes = File.getBytes(pathToSm + "/" + sm.header.MUSIC);
var sound = new Sound();
sound.loadCompressedDataFromByteArray(bytes.getData(), bytes.length);
FlxG.sound.playMusic(sound);
}
else
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
#else
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
#end
}

FlxG.sound.music.onComplete = endSong;
FlxG.sound.music.pause();

// Song duration in a float, useful for the time left feature
songLength = FlxG.sound.music.length;

if (FlxG.save.data.songPosition)
{
remove(songPosBG);
remove(songPosBar);
remove(songName);

songPosBG = new FlxSprite(0, 10).loadGraphic(Paths.image('healthBar'));
if (PlayStateChangeables.useDownscroll)
songPosBG.y = FlxG.height * 0.9 + 45;
songPosBG.screenCenter(X);
songPosBG.scrollFactor.set();
add(songPosBG);

songPosBar = new FlxBar(songPosBG.x
+ 4, songPosBG.y
+ 4, LEFT_TO_RIGHT, Std.int(songPosBG.width - 8), Std.int(songPosBG.height - 8), this,
'songPositionBar', 0, songLength
- 1000);
songPosBar.numDivisions = 1000;
songPosBar.scrollFactor.set();
songPosBar.createFilledBar(FlxColor.GRAY, FlxColor.LIME);
add(songPosBar);

var songName = new FlxText(songPosBG.x + (songPosBG.width / 2) - (SONG.song.length * 5), songPosBG.y, 0, SONG.song, 16);
if (PlayStateChangeables.useDownscroll)
songName.y -= 3;
songName.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
songName.scrollFactor.set();
add(songName);

songPosBG.cameras = [camHUD];
songPosBar.cameras = [camHUD];
songName.cameras = [camHUD];
}


notes = new FlxTypedGroup<Note>();
add(notes);

Expand Down

0 comments on commit 8d6e9d8

Please sign in to comment.