Skip to content

Commit 66bd033

Browse files
committed
fix things
1 parent e93d789 commit 66bd033

6 files changed

Lines changed: 33 additions & 46 deletions

File tree

src/funkin/data/StrumlineData.hx

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package funkin.data;
33
import flixel.util.FlxSort;
44
import funkin.objects.gameplay.strumline.NoteSprite;
55
import funkin.objects.gameplay.strumline.Strumline;
6-
import funkin.util.Controls;
6+
import funkin.util.FunkinControls;
77
import funkin.util.InputUtil;
88
import haxe.Json;
99

@@ -44,39 +44,23 @@ class StrumlineData
4444
data = cast Json.parse(dataContent);
4545
}
4646

47-
var lastCPUControlled:Null<Bool> = null;
48-
4947
public function update():Void
5048
{
51-
if (lastCPUControlled != data.computerControlled)
52-
{
53-
if (Controls.instance.pressed.has(controlPressed) && data.computerControlled)
54-
Controls.instance.pressed.remove(controlPressed);
55-
56-
if (!Controls.instance.pressed.has(controlPressed) && !data.computerControlled)
57-
Controls.instance.pressed.add(controlPressed);
58-
59-
if (Controls.instance.released.has(controlReleased) && data.computerControlled)
60-
Controls.instance.released.remove(controlReleased);
61-
62-
if (!Controls.instance.released.has(controlReleased) && !data.computerControlled)
63-
Controls.instance.released.add(controlReleased);
64-
65-
lastCPUControlled = data.computerControlled;
66-
}
49+
if (data.computerControlled)
50+
return;
6751

52+
controlPressed();
53+
controlReleased();
6854
handleNoteInput();
6955
}
7056

71-
var lastInputPressed:InputHit = {direction: -1, time: -1};
72-
7357
private function controlPressed():Void
7458
{
7559
var controlArray:Array<Bool> = [
76-
Controls.instance.NOTE_LEFT_P,
77-
Controls.instance.NOTE_DOWN_P,
78-
Controls.instance.NOTE_UP_P,
79-
Controls.instance.NOTE_RIGHT_P
60+
FunkinControls.instance.justPressed.NOTE_LEFT,
61+
FunkinControls.instance.justPressed.NOTE_DOWN,
62+
FunkinControls.instance.justPressed.NOTE_UP,
63+
FunkinControls.instance.justPressed.NOTE_RIGHT
8064
];
8165

8266
for (i in 0...controlArray.length)
@@ -85,26 +69,22 @@ class StrumlineData
8569
{
8670
var direction:NoteDirection = cast(i, NoteDirection);
8771
@:privateAccess
88-
if (strumline != null && !(lastInputPressed.direction == direction && lastInputPressed.time == conductorInUse.time))
72+
if (strumline != null)
8973
{
9074
strumline.currentlyPressed[direction] = true;
9175
notesPressed.push({direction: direction, time: conductorInUse.time});
92-
lastInputPressed.direction = direction;
93-
lastInputPressed.time = conductorInUse.time;
9476
}
9577
}
9678
}
9779
}
9880

99-
var lastInputReleased:InputHit = {direction: -1, time: -1};
100-
10181
private function controlReleased():Void
10282
{
10383
var controlArray:Array<Bool> = [
104-
Controls.instance.NOTE_LEFT_R,
105-
Controls.instance.NOTE_DOWN_R,
106-
Controls.instance.NOTE_UP_R,
107-
Controls.instance.NOTE_RIGHT_R
84+
FunkinControls.instance.justReleased.NOTE_LEFT,
85+
FunkinControls.instance.justReleased.NOTE_DOWN,
86+
FunkinControls.instance.justReleased.NOTE_UP,
87+
FunkinControls.instance.justReleased.NOTE_RIGHT
10888
];
10989

11090
for (i in 0...controlArray.length)
@@ -114,12 +94,10 @@ class StrumlineData
11494
{
11595
var direction:NoteDirection = cast(i, NoteDirection);
11696
@:privateAccess
117-
if (strumline != null && !(lastInputReleased.direction == direction && lastInputReleased.time == conductorInUse.time))
97+
if (strumline != null)
11898
{
11999
strumline.currentlyPressed[direction] = false;
120100
notesReleased.push({direction: direction, time: conductorInUse.time});
121-
lastInputReleased.direction = direction;
122-
lastInputReleased.time = conductorInUse.time;
123101
}
124102
}
125103
}

src/funkin/objects/gameplay/strumline/Strumline.hx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ class Strumline extends FlxSpriteGroup
183183
}
184184

185185
if (note.sustainSprite != null)
186+
{
187+
note.sustainSprite.parentWasHit = true;
186188
note.sustainSprite.currentlyHeld = true;
189+
}
187190

188191
note.kill();
189192
}
@@ -343,7 +346,8 @@ class Strumline extends FlxSpriteGroup
343346
if (sustainNote.data.time <= conductorInUse.time
344347
&& sustainNote.data.time + sustainNote.data.length >= conductorInUse.time
345348
&& sustainNote.data.direction == direction
346-
&& sustainNote.currentlyHeld)
349+
&& sustainNote.currentlyHeld
350+
&& sustainNote.parentWasHit)
347351
{
348352
trace('Is true!!');
349353
return true;
@@ -364,6 +368,7 @@ class Strumline extends FlxSpriteGroup
364368
// TODO: change false to downScroll
365369
return Constants.PIXELS_PER_MS * (conductorInUse.time - strumTime) * scrollSpeed * (false ? 1 : -1);
366370
}
371+
367372
override function set_camera(Value:FlxCamera):FlxCamera
368373
{
369374
if (camera != Value && renderingSquare != null)

src/funkin/objects/gameplay/strumline/SustainNoteSprite.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class SustainNoteSprite extends FunkinSprite
3030
*/
3131
public var currentlyHeld:Bool = false;
3232

33+
/**
34+
* If the parent note was hit already.
35+
*/
36+
public var parentWasHit:Bool = false;
37+
3338
/**
3439
* Sets up sustain sprite for use.
3540
* @param data The note data for this sustain note.

src/funkin/objects/ui/freeplay/FreeplayDJAtlas.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class FreeplayDJAtlas extends FlxAnimate
4646
if (instance?.symbol?.name?.startsWith('tt lights') && analyzerHelper.ready)
4747
{
4848
var nameSuffix:String = instance.symbol.name.substring('tt lights'.length);
49-
trace(nameSuffix);
5049

5150
var index:Null<Int> = Std.parseInt(nameSuffix);
5251
if (index == null)

src/funkin/states/gameplay/PlayState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class PlayState extends FunkinState
164164

165165
super.update(elapsed);
166166

167-
if (controls.BACK)
167+
if (controls.justPressed.BACK)
168168
FlxG.switchState(funkin.states.ui.MenuState.new);
169169
}
170170

src/funkin/states/ui/FreeplayState.hx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,21 @@ class FreeplayState extends FunkinState
318318

319319
if (curSelected == 0)
320320
{
321-
conductor.bpm = 145;
321+
conductor.changeBPM(145, false);
322322
var songPosToSetTo:Float = lastSongPos;
323323
lastSongPos = FlxG.sound.music.time;
324324
FlxG.sound.playMusic(Paths.content.audio('ui/freeplay/freeplayRandom'));
325-
FlxG.sound.music?.time = songPosToSetTo;
325+
FlxG.sound.music.time = songPosToSetTo;
326326
FlxG.sound.music?.fadeIn(2, 0, 1);
327327
isRandomPlaying = true;
328328
}
329329
else if (isRandomPlaying)
330330
{
331-
conductor.bpm = 102;
331+
conductor.changeBPM(102, false);
332332
var songPosToSetTo:Float = lastSongPos;
333333
lastSongPos = FlxG.sound.music?.time;
334334
FlxG.sound.playMusic(Paths.content.audio('ui/menu/freakyMenu'));
335-
FlxG.sound.music?.time = songPosToSetTo;
335+
FlxG.sound.music.time = songPosToSetTo;
336336
FlxG.sound.music?.fadeIn(2, 0, 1);
337337
isRandomPlaying = false;
338338
}
@@ -422,11 +422,11 @@ class FreeplayState extends FunkinState
422422
{
423423
if (isRandomPlaying)
424424
{
425-
conductor.bpm = 102;
425+
conductor.changeBPM(102, false);
426426
var songPosToSetTo:Float = lastSongPos;
427427
lastSongPos = FlxG.sound.music?.time;
428428
FlxG.sound.playMusic(Paths.content.audio('ui/menu/freakyMenu'));
429-
FlxG.sound.music?.time = songPosToSetTo;
429+
FlxG.sound.music.time = songPosToSetTo;
430430
FlxG.sound.music?.fadeIn(2, 0, 1);
431431
isRandomPlaying = false;
432432
}

0 commit comments

Comments
 (0)