Skip to content

Commit

Permalink
move some strum logic to StrumLineGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed May 26, 2024
1 parent 75a926f commit 930510a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 48 deletions.
47 changes: 4 additions & 43 deletions source/funkin/objects/NotesGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -597,52 +597,13 @@ class NotesGroup extends Group
inline function checkStrumAnims():Void
{
if (!inBotplay) {
checkStrums(playerStrums.members);
checkOverSinging(boyfriend, playerStrums);
playerStrums.checkStrums();
playerStrums.checkCharSinging(boyfriend);
}

if (!dadBotplay) {
checkStrums(opponentStrums.members);
checkOverSinging(dad, opponentStrums);
}
}

function checkStrums(array:Array<NoteStrum>):Void
{
array.fastForEach((strum, i) -> {
if (strum.animation.curAnim != null) // Lil null check
{
if (strum.getControl(JUST_PRESSED)) if (!strum.animation.curAnim.name.startsWith('confirm'))
strum.playStrumAnim('pressed');

if (!strum.getControl())
strum.playStrumAnim('static');
}
});
}

function checkOverSinging(char:Character, strums:StrumLineGroup):Void
{
if (char == null) return;
if (char.animation.curAnim == null) return;

var name:String = char.animation.curAnim.name;
var overSinging:Bool =
(char.holdTimer > (Conductor.stepCrochetMills * Conductor.STEPS_PER_BEAT)
&& name.startsWith('sing')
&& !name.endsWith('miss'));

if (overSinging) {
var isHolding:Bool = false;
strums.members.fastForEach((strum, i) -> {
if (strum.animation.curAnim.name.startsWith('confirm')) {
isHolding = true;
break;
}
});

if (!isHolding)
char.restartDance();
opponentStrums.checkStrums();
opponentStrums.checkCharSinging(dad);
}
}

Expand Down
42 changes: 41 additions & 1 deletion source/funkin/objects/note/StrumLineGroup.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package funkin.objects.note;

class StrumLineGroup extends TypedSpriteGroup<NoteStrum> {
class StrumLineGroup extends TypedSpriteGroup<NoteStrum>
{
public var initPos:Array<FlxPoint> = [];
public static var strumLineY:Float = 50;

Expand Down Expand Up @@ -47,6 +48,45 @@ class StrumLineGroup extends TypedSpriteGroup<NoteStrum> {
});
}

public function checkStrums():Void {
members.fastForEach((strum, i) -> {
if (strum.animation.curAnim != null) // Lil null check
{
if (strum.getControl(JUST_PRESSED)) if (!strum.animation.curAnim.name.startsWith('confirm'))
strum.playStrumAnim('pressed');

if (!strum.getControl())
strum.playStrumAnim('static');
}
});
}

public function checkCharSinging(char:Character):Void {
if (char == null) return;
if (char.animation.curAnim == null) return;

if (char.holdTimer > (Conductor.stepCrochetMills * Conductor.STEPS_PER_BEAT))
{
final name:String = char.animation.curAnim.name;

// Character is over-singing
if (name.startsWith('sing')) if (!name.endsWith('miss'))
{
var isHolding:Bool = false;
members.fastForEach((strum, i) ->
{
if (strum.animation.curAnim != null) if (strum.animation.curAnim.name.startsWith('confirm')) {
isHolding = true;
break;
}
});

if (!isHolding)
char.restartDance();
}
}
}

public function addStrum(noteData:Int = 0) {
if (members.length >= 9) return null; // STOP
final strumX:Float = startX + seperateWidth * noteData;
Expand Down
11 changes: 7 additions & 4 deletions source/funkin/substates/CharSelectSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ class CharSelectSubstate extends MusicBeatSubstate

override public function update(elapsed:Float):Void {
super.update(elapsed);
if (getKey('UI_UP', JUST_PRESSED)) changeSelection(-1);
if (getKey('UI_DOWN', JUST_PRESSED)) changeSelection(1);
if (getKey('UI_LEFT', JUST_PRESSED)) changeFolder(-1);
if (getKey('UI_RIGHT', JUST_PRESSED)) changeFolder(1);

if (getKey('UI_UP', JUST_PRESSED)) changeSelection(-1);
else if (getKey('UI_DOWN', JUST_PRESSED)) changeSelection(1);

if (getKey('UI_LEFT', JUST_PRESSED)) changeFolder(-1);
else if (getKey('UI_RIGHT', JUST_PRESSED)) changeFolder(1);

if (getKey('ACCEPT', JUST_PRESSED)) selectChar();
else if (getKey('BACK', JUST_PRESSED)) close();
}
Expand Down

0 comments on commit 930510a

Please sign in to comment.