-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggested by bluecolorsin!
- Loading branch information
Showing
3 changed files
with
73 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package funkin.util.frontend.modifiers; | ||
|
||
import funkin.util.frontend.ModchartManager.Modifiers; | ||
|
||
class ShakeModifier extends BasicModifier | ||
{ | ||
public function new() { | ||
super(SHAKE, false); | ||
} | ||
|
||
// Force shake running at 24 fps | ||
var timeElapsed:Float = 0; | ||
|
||
var shakeX:Float = 0; | ||
var shakeY:Float = 0; | ||
|
||
override function manageStrumUpdate(strum:NoteStrum, elapsed:Float, beat:Float) { | ||
var percent:Float = data[0]; | ||
if (FunkMath.isZero(percent)) | ||
return; | ||
|
||
var speed:Float = data[1]; | ||
timeElapsed += (elapsed * speed); | ||
|
||
while (timeElapsed > (1 / 24)) { | ||
timeElapsed -= (1 / 24); | ||
|
||
shakeX = FlxG.random.float(-1, 1) * scaleWidth(percent); | ||
shakeY = FlxG.random.float(-1, 1) * scaleHeight(percent); | ||
} | ||
|
||
strum.xModchart += shakeX; | ||
strum.yModchart += shakeY; | ||
} | ||
|
||
// [percent] | ||
override function getDefaultValues() { | ||
return [0.1, 1]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters