Skip to content

Commit

Permalink
update to latest libraries
Browse files Browse the repository at this point in the history
add some animation thingy
make restarting song take less time
  • Loading branch information
TheRealJake12 committed Nov 10, 2023
1 parent ecab355 commit 0685cec
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 75 deletions.
3 changes: 2 additions & 1 deletion assets/preload/data/eventList.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
BPM Change
Scroll Speed Change
Scroll Speed Change
Play Animation
3 changes: 2 additions & 1 deletion source/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ class Character extends FlxSprite
var daStrumTime:Float = (songNotes[0] - FlxG.save.data.offset - PlayState.SONG.offset) / PlayState.songMultiplier;
if (daStrumTime < 0)
daStrumTime = 0;
var daBeat = TimingStruct.getBeatFromTime(daStrumTime);

var daNoteData:Int = Std.int(songNotes[1] % 4);

Expand All @@ -359,7 +360,7 @@ class Character extends FlxSprite
oldNote = PlayState.instance.unspawnNotes[Std.int(PlayState.instance.unspawnNotes.length - 1)];
else
oldNote = null;
var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote, false, false, false, songNotes[4]);
var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote, false, false, false, songNotes[4], daBeat);

animationNotes.push(swagNote);
}
Expand Down
25 changes: 2 additions & 23 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -768,31 +768,10 @@ class FreeplayState extends MusicBeatState
}
}

#if cpp
@:privateAccess
if (FlxG.sound.music.playing && !MainMenuState.freakyPlaying)
{
if (FlxG.sound.music.playing && !MainMenuState.freakyPlaying)
{
#if (lime >= "8.0.0")
FlxG.sound.music._channel.__source.__backend.setPitch(rate);
#else
lime.media.openal.AL.sourcef(FlxG.sound.music._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, rate);
#end
}
FlxG.sound.music.pitch = rate;
}
#elseif html5
@:privateAccess
{
if (FlxG.sound.music.playing && !MainMenuState.freakyPlaying)
{
#if (lime >= "8.0.0" && lime_howlerjs)
FlxG.sound.music._channel.__source.__backend.setPitch(rate);
#else
FlxG.sound.music._channel.__source.__backend.parent.buffer.__srcHowl.rate(rate);
#end
}
}
#end

#if html5
diffCalcText.text = "RATING: N/A";
Expand Down
2 changes: 1 addition & 1 deletion source/KadeEngineData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class KadeEngineData
FlxG.save.data.autoSaving = true;

if (FlxG.save.data.shaders == null)
FlxG.save.data.shaders = false;
FlxG.save.data.shaders = false;

if (FlxG.save.data.volume != null)
{
Expand Down
12 changes: 7 additions & 5 deletions source/ModchartState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ class ModchartState

var path = Sys.getCwd() + "assets/data/songs/" + PlayState.SONG.songId + '/';

#if FEATURE_STEPMANIA
if (PlayState.isSM)
path = PlayState.pathToSm + "/";
#end

var data:BitmapData = BitmapData.fromFile(path + spritePath + ".png");

Expand Down Expand Up @@ -439,8 +441,10 @@ class ModchartState
}

var path = Paths.lua('songs/${PlayState.SONG.songId}/modchart');
#if FEATURE_STEPMANIA
if (PlayState.isSM)
path = PlayState.pathToSm + "/modchart.lua";
#end

var result = LuaL.dofile(lua, path); // execute le file

Expand All @@ -449,8 +453,8 @@ class ModchartState
Application.current.window.alert("LUA COMPILE ERROR:\n" + Lua.tostring(lua, result), "Kade Engine Modcharts");
FlxG.log.warn(["LUA COMPILE ERROR:\n" + Lua.tostring(lua, result)]);
MusicBeatState.switchState(new FreeplayState());
return;
lua = null;
return;
}

// get some fukin globals up in here bois
Expand Down Expand Up @@ -479,7 +483,7 @@ class ModchartState

setVar("followXOffset", 0);
setVar("followYOffset", 0);

setVar("strumLine1Visible", true);
setVar("strumLine2Visible", true);

Expand Down Expand Up @@ -518,7 +522,6 @@ class ModchartState
}
Debug.logTrace("getProp");
return Reflect.getProperty(PlayState.instance, variable);

});
Lua_helper.add_callback(lua, "setProperty", function(variable:String, value:Dynamic)
{
Expand All @@ -537,7 +540,6 @@ class ModchartState
}
Debug.logTrace("setProp");
return Reflect.setProperty(PlayState.instance, variable, value);

});
Lua_helper.add_callback(lua, "getPropertyFromGroup", function(obj:String, index:Int, variable:Dynamic)
{
Expand Down Expand Up @@ -733,7 +735,7 @@ class ModchartState
case 'camGame' | 'game':
return PlayState.instance.camGame;
case 'overlayCam' | 'overlay':
return PlayState.instance.overlayCam;
return PlayState.instance.overlayCam;
}
return PlayState.instance.camGame;
}
Expand Down
1 change: 1 addition & 0 deletions source/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class PauseSubState extends MusicBeatSubstate

case "Restart Song":
PlayState.startTime = 0;
FlxTransitionableState.skipNextTransOut = true;
MusicBeatState.resetState();
case 'Change Difficulty':
menuItems = difficultyChoices;
Expand Down
75 changes: 45 additions & 30 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,6 @@ class PlayState extends MusicBeatState
{
case 'halloween':
camPos = new FlxPoint(gf.getMidpoint().x, gf.getMidpoint().y);
case 'tank':
if (SONG.player2 == 'tankman')
camPos = new FlxPoint(436.5, 534.5);
case 'stage':
if (dad.replacesGF)
camPos = new FlxPoint(dad.getGraphicMidpoint().x + dad.camPos[0] - 200, dad.getGraphicMidpoint().y + dad.camPos[1]);
Expand Down Expand Up @@ -897,9 +894,6 @@ class PlayState extends MusicBeatState
case "tank":
gf.y += 10;
gf.x -= 30;
boyfriend.x += 40;
boyfriend.y += 0;
dad.y += 60;
dad.x -= 80;

if (SONG.gfVersion != 'pico-speaker')
Expand Down Expand Up @@ -1871,7 +1865,7 @@ class PlayState extends MusicBeatState
// speedChanged = true;
if (generatedMusic)
{
var ratio:Float = value / scrollSpeed;
var ratio:Float = value / scrollSpeed / songMultiplier;
for (note in notes)
{
if (note.animation.curAnim != null)
Expand Down Expand Up @@ -3148,18 +3142,18 @@ class PlayState extends MusicBeatState
@:privateAccess
{
#if (lime >= "8.0.0")
inst._channel.__source.__backend.setPitch(songMultiplier);
inst.pitch = songMultiplier;
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
vocals._channel.__source.__backend.setPitch(songMultiplier);
vocals.pitch = songMultiplier;
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.setPitch(songMultiplier);
vocalsEnemy._channel.__source.__backend.setPitch(songMultiplier);
vocalsPlayer.pitch = songMultiplier;
vocalsEnemy.pitch = songMultiplier;
}
}
#else
Expand Down Expand Up @@ -3250,6 +3244,7 @@ class PlayState extends MusicBeatState
public var updateFrame = 0;

public var pastScrollChanges:Array<Song.Event> = [];
public var pastAnimationPlays:Array<Song.Event> = [];

var currentLuaIndex = 0;

Expand Down Expand Up @@ -3332,18 +3327,18 @@ class PlayState extends MusicBeatState
@:privateAccess
{
#if (lime >= "8.0.0")
inst._channel.__source.__backend.setPitch(songMultiplier);
inst.pitch = songMultiplier;
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
vocals._channel.__source.__backend.setPitch(songMultiplier);
vocals.pitch = songMultiplier;
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.setPitch(songMultiplier);
vocalsEnemy._channel.__source.__backend.setPitch(songMultiplier);
vocalsPlayer.pitch = songMultiplier;
vocalsEnemy.pitch = songMultiplier;
}
}
#elseif html5
Expand Down Expand Up @@ -3515,6 +3510,26 @@ class PlayState extends MusicBeatState
changeScrollSpeed(newScroll, i.value2, FlxEase.linear);
}
speedChanged = true;
case "Play Animation":
if (i.position <= curDecimalBeat && !pastAnimationPlays.contains(i))
{
pastAnimationPlays.push(i);
var char:Character = dad;
switch (i.value.toLowerCase())
{
case 'bf' | 'boyfriend':
char = boyfriend;
case 'gf' | 'girlfriend':
char = gf;
default:
char = dad;
}

if (char != null)
{
char.playAnim(i.value2, true);
}
}
}
}
}
Expand Down Expand Up @@ -4048,20 +4063,6 @@ class PlayState extends MusicBeatState
}
}

if (!daNote.mustPress)
{
if (Conductor.songPosition >= daNote.strumTime && daNote.canPlayAnims)
opponentNoteHit(daNote);
}
else
{
if (PlayStateChangeables.botPlay)
handleBotplay(daNote);
else if (!PlayStateChangeables.botPlay && daNote.isSustainNote && daNote.canBeHit && daNote.mustPress && keys[daNote.noteData]
&& daNote.sustainActive)
handleHolds(daNote);
}

if (!daNote.modifiedByLua)
{
daNote.visible = strum.members[Math.floor(Math.abs(daNote.noteData))].visible;
Expand All @@ -4076,6 +4077,20 @@ class PlayState extends MusicBeatState
}
}

if (!daNote.mustPress)
{
if (Conductor.songPosition >= daNote.strumTime && daNote.canPlayAnims)
opponentNoteHit(daNote);
}
else
{
if (PlayStateChangeables.botPlay)
handleBotplay(daNote);
else if (!PlayStateChangeables.botPlay && daNote.isSustainNote && daNote.canBeHit && daNote.mustPress && keys[daNote.noteData]
&& daNote.sustainActive)
handleHolds(daNote);
}

// there was some code idk what it did but it fucked with color quantization shit. ik its a feature not many like but I like it.

if (!daNote.mustPress && FlxG.save.data.middleScroll && !executeModchart)
Expand Down Expand Up @@ -4220,13 +4235,13 @@ class PlayState extends MusicBeatState
&& daNote.causesMisses)
{
// health -= 0.05; // give a health punishment for failing a LN
noteMiss(daNote.noteData, daNote);
for (i in daNote.parent.children)
{
i.sustainActive = false;
}
if (daNote.parent.wasGoodHit)
{
// misses++;
totalNotesHit -= 1;
}
updateAccuracy();
Expand Down
8 changes: 4 additions & 4 deletions source/debug/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ class ChartingState extends MusicBeatState
// No more Native restrictions bitches. https://github.com/openfl/lime/pull/1510. WEEK 8 LEAK??
#if desktop
#if (lime >= "8.0.0")
inst._channel.__source.__backend.setPitch(speed);
inst.pitch = speed;
#else
lime.media.openal.AL.sourcef(inst._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, speed);
#end
Expand All @@ -2241,7 +2241,7 @@ class ChartingState extends MusicBeatState
if (vocals != null && vocals.length > 0)
{
#if (lime >= "8.0.0")
vocals._channel.__source.__backend.setPitch(speed);
vocals.pitch = speed;
#else
lime.media.openal.AL.sourcef(vocals._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, speed);
#end
Expand All @@ -2252,7 +2252,7 @@ class ChartingState extends MusicBeatState
if (vocalsPlayer != null && vocalsPlayer.length > 0)
{
#if (lime >= "8.0.0")
vocalsPlayer._channel.__source.__backend.setPitch(speed);
vocalsPlayer.pitch = speed;
#else
lime.media.openal.AL.sourcef(vocalsPlayer._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, speed);
#end
Expand All @@ -2261,7 +2261,7 @@ class ChartingState extends MusicBeatState
if (vocalsEnemy != null && vocalsEnemy.length > 0)
{
#if (lime >= "8.0.0")
vocalsEnemy._channel.__source.__backend.setPitch(speed);
vocalsEnemy.pitch = speed;
#else
lime.media.openal.AL.sourcef(vocalsEnemy._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, speed);
#end
Expand Down
Loading

0 comments on commit 0685cec

Please sign in to comment.