pixel notes no longer crash the game. their sustain notes look weird but hey, it works at least
Added "addWiggleEffect" for the wiggle effects.. hopefully i did (closes #246)
This commit is contained in:
JordanSantiagoYT
2024-03-17 00:01:36 -04:00
parent 932a3ef6ac
commit 8a3cbed07e
4 changed files with 39 additions and 14 deletions

View File

@@ -34,6 +34,8 @@ import flixel.util.FlxSave;
import flixel.addons.transition.FlxTransitionableState;
import flixel.system.FlxAssets.FlxShader;
import Shaders;
import WiggleEffect;
import WiggleEffect.WiggleEffectType;
#if (!flash && sys)
import flixel.addons.display.FlxRuntimeShader;
@@ -2813,7 +2815,17 @@ class FunkinLua {
{
cameraFromString(cameraName).filters = [];
});
Lua_helper.add_callback(lua, "addWiggleEffect", function(camera:String, effectType:WiggleEffectType, waveSpeed:Float = 0.1,waveFrq:Float = 0.1,waveAmp:Float = 0.1, ?verticalStrength:Float = 1, ?horizontalStrength:Float = 1) {
if (effectType != HEAT_WAVE_BOTH) PlayState.instance.addShaderToCamera(camera, new WiggleEffect(effectType, waveSpeed, waveFrq, waveAmp));
else
{
PlayState.instance.addShaderToCamera(camera, new WiggleEffect(HEAT_WAVE_VERTICAL, waveSpeed * verticalStrength,waveFrq * verticalStrength,waveAmp * verticalStrength));
PlayState.instance.addShaderToCamera(camera, new WiggleEffect(HEAT_WAVE_HORIZONTAL, waveSpeed * horizontalStrength,waveFrq * horizontalStrength,waveAmp * horizontalStrength));
}
});
Lua_helper.add_callback(lua, "addGlitchEffect", function(camera:String,waveSpeed:Float = 0.1,waveFrq:Float = 0.1,waveAmp:Float = 0.1) {
PlayState.instance.addShaderToCamera(camera, new GlitchEffect(waveSpeed,waveFrq,waveAmp));

View File

@@ -157,9 +157,6 @@ class Note extends FlxSprite
}
private function set_texture(value:String):String {
if(texture != value && ClientPrefs.showNotes && PlayState.isPixelStage && inEditor) {
reloadNote('', value);
}
if (!inEditor && !PlayState.isPixelStage)
{
if (!Paths.noteSkinFramesMap.exists(value)) Paths.initNote(4, value);
@@ -536,12 +533,11 @@ class Note extends FlxSprite
}
function loadPixelNoteAnims() {
if(isSustainNote) {
animation.add(colArray[noteData] + 'holdend', [pixelInt[noteData] + 4]);
animation.add(colArray[noteData] + 'hold', [pixelInt[noteData]]);
} else {
animation.add(colArray[noteData] + 'Scroll', [pixelInt[noteData] + 4]);
}
if(isSustainNote)
{
animation.add(colArray[noteData] + 'holdend', [noteData + 4], 24, true);
animation.add(colArray[noteData] + 'hold', [noteData], 24, true);
} else animation.add(colArray[noteData] + 'Scroll', [noteData + 4], 24, true);
}
public function updateNoteSkin(noteskin:String) {
@@ -620,6 +616,11 @@ class Note extends FlxSprite
{
offsetX = 36.5;
scale.set(0.7, animation != null && animation.curAnim != null && animation.curAnim.name.endsWith('end') ? 1 : Conductor.stepCrochet * 0.0105 * (songSpeed * multSpeed) * sustainScale);
if (PlayState.isPixelStage)
{
scale.x *= PlayState.daPixelZoom;
scale.y *= PlayState.daPixelZoom;
}
}
updateHitbox();
@@ -710,12 +711,12 @@ class Note extends FlxSprite
noteData = Std.int(chartNoteData.noteData % 4);
noteType = chartNoteData.noteType;
animSuffix = chartNoteData.animSuffix;
if (chartNoteData.noteskin.length > 0 && chartNoteData.noteskin != '' && chartNoteData.noteskin != texture) texture = 'noteskins/' + chartNoteData.noteskin;
if (chartNoteData.texture.length > 0 && chartNoteData.texture != texture) texture = chartNoteData.texture;
noAnimation = noMissAnimation = chartNoteData.noAnimation;
mustPress = chartNoteData.mustPress;
gfNote = chartNoteData.gfNote;
isSustainNote = chartNoteData.isSustainNote;
if (chartNoteData.noteskin.length > 0 && chartNoteData.noteskin != '' && chartNoteData.noteskin != texture) texture = 'noteskins/' + chartNoteData.noteskin;
if (chartNoteData.texture.length > 0 && chartNoteData.texture != texture) texture = chartNoteData.texture;
sustainLength = chartNoteData.sustainLength;
sustainScale = chartNoteData.sustainScale;
@@ -725,6 +726,7 @@ class Note extends FlxSprite
hitCausesMiss = chartNoteData.hitCausesMiss;
multSpeed = chartNoteData.multSpeed;
if (PlayState.isPixelStage) reloadNote('', texture);
animation.play(colArray[noteData % 4] + 'Scroll');
if (isSustainNote) animation.play(colArray[noteData % 4] + (chartNoteData.isSustainEnd ? 'holdend' : 'hold'));

View File

@@ -5195,7 +5195,7 @@ if (ClientPrefs.showNPS && (notesHitDateArray.length > 0 || oppNotesHitDateArray
dunceNote.row = Conductor.secsToRow(dunceNote.strumTime);
if(noteRows[dunceNote.mustPress?0:1][dunceNote.row] == null)
noteRows[dunceNote.mustPress?0:1][dunceNote.row] = [];
if (noteRows[dunceNote.mustPress?0:1][dunceNote.row][0] == null) noteRows[dunceNote.mustPress ? 0 : 1][dunceNote.row].push(dunceNote);
if (noteRows[dunceNote.mustPress?0:1][dunceNote.row] == null) noteRows[dunceNote.mustPress ? 0 : 1][dunceNote.row].push(dunceNote);
}
dunceNote.scrollFactor.set();

View File

@@ -10,6 +10,7 @@ enum WiggleEffectType
HEAT_WAVE_HORIZONTAL;
HEAT_WAVE_VERTICAL;
FLAG;
HEAT_WAVE_BOTH;
}
class WiggleEffect
@@ -20,9 +21,13 @@ class WiggleEffect
public var waveFrequency(default, set):Float = 0;
public var waveAmplitude(default, set):Float = 0;
public function new():Void
public function new(typeOfEffect:WiggleEffectType = DREAMY, waveSpeed:Float = 0, waveFrequency:Float = 0, waveAmplitude:Float = 0):Void
{
shader.uTime.value = [0];
this.waveSpeed = waveSpeed;
this.waveFrequency = waveFrequency;
this.waveAmplitude = waveAmplitude;
this.effectType = effectType;
}
public function update(elapsed:Float):Void
@@ -76,6 +81,7 @@ class WiggleShader extends FlxShader
const int EFFECT_TYPE_HEAT_WAVE_HORIZONTAL = 2;
const int EFFECT_TYPE_HEAT_WAVE_VERTICAL = 3;
const int EFFECT_TYPE_FLAG = 4;
const int EFFECT_TYPE_HEAT_WAVE_BOTH = 5;
uniform int effectType;
@@ -122,6 +128,11 @@ class WiggleShader extends FlxShader
y = sin(pt.y * uFrequency + 10.0 * pt.x + uTime * uSpeed) * uWaveAmplitude;
x = sin(pt.x * uFrequency + 5.0 * pt.y + uTime * uSpeed) * uWaveAmplitude;
}
else if (effectType == EFFECT_TYPE_HEAT_WAVE_BOTH)
{
x = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude;
y = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude;
}
return vec2(pt.x + x, pt.y + y);
}