mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 08:07:54 -05:00
THORNS AND EVIL MAN
This commit is contained in:
parent
f306e603be
commit
c66eb94ccf
6 changed files with 361 additions and 17 deletions
|
@ -422,6 +422,27 @@ class Character extends FlxSprite
|
|||
|
||||
antialiasing = false;
|
||||
|
||||
case 'spirit':
|
||||
frames = FlxAtlasFrames.fromSpriteSheetPacker('assets/images/weeb/spirit.png', 'assets/images/weeb/spirit.txt');
|
||||
animation.addByPrefix('idle', "idle spirit_", 24, false);
|
||||
animation.addByPrefix('singUP', "up_", 24, false);
|
||||
animation.addByPrefix('singRIGHT', "right_", 24, false);
|
||||
animation.addByPrefix('singLEFT', "left_", 24, false);
|
||||
animation.addByPrefix('singDOWN', "spirit down_", 24, false);
|
||||
|
||||
addOffset('idle', -220, -280);
|
||||
addOffset('singUP', -220, -240);
|
||||
addOffset("singRIGHT", -220, -280);
|
||||
addOffset("singLEFT", -200, -280);
|
||||
addOffset("singDOWN", 170, 110);
|
||||
|
||||
setGraphicSize(Std.int(width * 6));
|
||||
updateHitbox();
|
||||
|
||||
playAnim('idle');
|
||||
|
||||
antialiasing = false;
|
||||
|
||||
case 'parents-christmas':
|
||||
frames = FlxAtlasFrames.fromSparrow('assets/images/christmas/mom_dad_christmas_assets.png',
|
||||
'assets/images/christmas/mom_dad_christmas_assets.xml');
|
||||
|
|
|
@ -31,12 +31,16 @@ class DialogueBox extends FlxSpriteGroup
|
|||
var portraitRight:FlxSprite;
|
||||
|
||||
var handSelect:FlxSprite;
|
||||
var bgFade:FlxSprite;
|
||||
|
||||
public function new(talkingRight:Bool = true, ?dialogueList:Array<String>)
|
||||
{
|
||||
super();
|
||||
|
||||
var bgFade:FlxSprite = new FlxSprite(-200, -200).makeGraphic(Std.int(FlxG.width * 1.3), Std.int(FlxG.height * 1.3), 0xFFB3DFd8);
|
||||
FlxG.sound.playMusic('assets/music/Lunchbox' + TitleState.soundExt, 0);
|
||||
FlxG.sound.music.fadeIn(1, 0, 0.8);
|
||||
|
||||
bgFade = new FlxSprite(-200, -200).makeGraphic(Std.int(FlxG.width * 1.3), Std.int(FlxG.height * 1.3), 0xFFB3DFd8);
|
||||
bgFade.scrollFactor.set();
|
||||
bgFade.alpha = 0;
|
||||
add(bgFade);
|
||||
|
@ -130,10 +134,31 @@ class DialogueBox extends FlxSpriteGroup
|
|||
{
|
||||
remove(dialogue);
|
||||
|
||||
FlxG.sound.play('assets/sounds/clickText' + TitleState.soundExt, 0.8);
|
||||
|
||||
if (dialogueList[1] == null)
|
||||
{
|
||||
if (!isEnding)
|
||||
{
|
||||
isEnding = true;
|
||||
FlxG.sound.music.fadeOut(2.2, 0);
|
||||
|
||||
new FlxTimer().start(0.2, function(tmr:FlxTimer)
|
||||
{
|
||||
box.alpha -= 1 / 5;
|
||||
bgFade.alpha -= 1 / 5 * 0.7;
|
||||
portraitLeft.visible = false;
|
||||
portraitRight.visible = false;
|
||||
swagDialogue.alpha -= 1 / 5;
|
||||
dropText.alpha = swagDialogue.alpha;
|
||||
}, 5);
|
||||
|
||||
new FlxTimer().start(1.2, function(tmr:FlxTimer)
|
||||
{
|
||||
finishThing();
|
||||
kill();
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -145,6 +170,8 @@ class DialogueBox extends FlxSpriteGroup
|
|||
super.update(elapsed);
|
||||
}
|
||||
|
||||
var isEnding:Bool = false;
|
||||
|
||||
function startDialogue():Void
|
||||
{
|
||||
cleanDialog();
|
||||
|
@ -155,7 +182,7 @@ class DialogueBox extends FlxSpriteGroup
|
|||
|
||||
// swagDialogue.text = ;
|
||||
swagDialogue.resetText(dialogueList[0]);
|
||||
swagDialogue.start(0.02, true);
|
||||
swagDialogue.start(0.04, true);
|
||||
|
||||
switch (curCharacter)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ class HealthIcon extends FlxSprite
|
|||
animation.add('face', [10, 11], 0, false, isPlayer);
|
||||
animation.add('dad', [12, 13], 0, false, isPlayer);
|
||||
animation.add('senpai', [22, 22], 0, false, isPlayer);
|
||||
animation.add('spirit', [23, 23], 0, false, isPlayer);
|
||||
animation.add('bf-old', [14, 15], 0, false, isPlayer);
|
||||
animation.add('gf', [16], 0, false, isPlayer);
|
||||
animation.add('parents-christmas', [17], 0, false, isPlayer);
|
||||
|
|
|
@ -6,6 +6,8 @@ import flixel.math.FlxMath;
|
|||
import flixel.util.FlxColor;
|
||||
import polymod.format.ParseRules.TargetSignatureElement;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class Note extends FlxSprite
|
||||
{
|
||||
public var strumTime:Float = 0;
|
||||
|
@ -75,6 +77,32 @@ class Note extends FlxSprite
|
|||
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
|
||||
updateHitbox();
|
||||
|
||||
case 'schoolEvil': // COPY PASTED CUZ I AM LAZY
|
||||
loadGraphic('assets/images/weeb/pixelUI/arrows-pixels.png', true, 17, 17);
|
||||
|
||||
animation.add('greenScroll', [6]);
|
||||
animation.add('redScroll', [7]);
|
||||
animation.add('blueScroll', [5]);
|
||||
animation.add('purpleScroll', [4]);
|
||||
|
||||
if (isSustainNote)
|
||||
{
|
||||
loadGraphic('assets/images/weeb/pixelUI/arrowEnds.png', true, 7, 6);
|
||||
|
||||
animation.add('purpleholdend', [4]);
|
||||
animation.add('greenholdend', [6]);
|
||||
animation.add('redholdend', [7]);
|
||||
animation.add('blueholdend', [5]);
|
||||
|
||||
animation.add('purplehold', [0]);
|
||||
animation.add('greenhold', [2]);
|
||||
animation.add('redhold', [3]);
|
||||
animation.add('bluehold', [1]);
|
||||
}
|
||||
|
||||
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
|
||||
updateHitbox();
|
||||
|
||||
default:
|
||||
frames = FlxAtlasFrames.fromSparrow('assets/images/NOTE_assets.png', 'assets/images/NOTE_assets.xml');
|
||||
|
||||
|
@ -139,7 +167,7 @@ class Note extends FlxSprite
|
|||
|
||||
x -= width / 2;
|
||||
|
||||
if (PlayState.curStage == 'school')
|
||||
if (PlayState.curStage.startsWith('school'))
|
||||
x += 30;
|
||||
|
||||
if (prevNote.isSustainNote)
|
||||
|
|
|
@ -2,6 +2,7 @@ package;
|
|||
|
||||
import Section.SwagSection;
|
||||
import Song.SwagSong;
|
||||
import WiggleEffect.WiggleEffectType;
|
||||
import flixel.FlxBasic;
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
|
@ -11,6 +12,10 @@ import flixel.FlxSprite;
|
|||
import flixel.FlxState;
|
||||
import flixel.FlxSubState;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
import flixel.addons.effects.FlxTrail;
|
||||
import flixel.addons.effects.FlxTrailArea;
|
||||
import flixel.addons.effects.chainable.FlxEffectSprite;
|
||||
import flixel.addons.effects.chainable.FlxWaveEffect;
|
||||
import flixel.graphics.atlas.FlxAtlas;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
|
@ -30,6 +35,7 @@ import flixel.util.FlxTimer;
|
|||
import haxe.Json;
|
||||
import lime.utils.Assets;
|
||||
import openfl.display.BlendMode;
|
||||
import openfl.display.StageQuality;
|
||||
import openfl.filters.ShaderFilter;
|
||||
|
||||
using StringTools;
|
||||
|
@ -97,6 +103,7 @@ class PlayState extends MusicBeatState
|
|||
var santa:FlxSprite;
|
||||
|
||||
var bgGirls:BackgroundGirls;
|
||||
var wiggleShit:WiggleEffect = new WiggleEffect();
|
||||
|
||||
var talking:Bool = true;
|
||||
var songScore:Int = 0;
|
||||
|
@ -335,7 +342,7 @@ class PlayState extends MusicBeatState
|
|||
evilSnow.antialiasing = true;
|
||||
add(evilSnow);
|
||||
}
|
||||
else if (SONG.song.toLowerCase() == 'senpai' || SONG.song.toLowerCase() == 'roses' || SONG.song.toLowerCase() == 'thorns')
|
||||
else if (SONG.song.toLowerCase() == 'senpai' || SONG.song.toLowerCase() == 'roses')
|
||||
{
|
||||
curStage = 'school';
|
||||
|
||||
|
@ -397,6 +404,68 @@ class PlayState extends MusicBeatState
|
|||
bgGirls.updateHitbox();
|
||||
add(bgGirls);
|
||||
}
|
||||
else if (SONG.song.toLowerCase() == 'thorns')
|
||||
{
|
||||
curStage = 'schoolEvil';
|
||||
|
||||
var waveEffectBG = new FlxWaveEffect(FlxWaveMode.ALL, 2, -1, 3, 2);
|
||||
var waveEffectFG = new FlxWaveEffect(FlxWaveMode.ALL, 2, -1, 5, 2);
|
||||
|
||||
var posX = 400;
|
||||
var posY = 200;
|
||||
|
||||
var bg:FlxSprite = new FlxSprite(posX, posY);
|
||||
bg.frames = FlxAtlasFrames.fromSparrow('assets/images/weeb/animatedEvilSchool.png', 'assets/images/weeb/animatedEvilSchool.xml');
|
||||
bg.animation.addByPrefix('idle', 'background 2', 24);
|
||||
bg.animation.play('idle');
|
||||
bg.scrollFactor.set(0.8, 0.9);
|
||||
bg.scale.set(6, 6);
|
||||
add(bg);
|
||||
|
||||
/*
|
||||
var bg:FlxSprite = new FlxSprite(posX, posY).loadGraphic('assets/images/weeb/evilSchoolBG.png');
|
||||
bg.scale.set(6, 6);
|
||||
// bg.setGraphicSize(Std.int(bg.width * 6));
|
||||
// bg.updateHitbox();
|
||||
add(bg);
|
||||
|
||||
var fg:FlxSprite = new FlxSprite(posX, posY).loadGraphic('assets/images/weeb/evilSchoolFG.png');
|
||||
fg.scale.set(6, 6);
|
||||
// fg.setGraphicSize(Std.int(fg.width * 6));
|
||||
// fg.updateHitbox();
|
||||
add(fg);
|
||||
|
||||
wiggleShit.effectType = WiggleEffectType.DREAMY;
|
||||
wiggleShit.waveAmplitude = 0.01;
|
||||
wiggleShit.waveFrequency = 60;
|
||||
wiggleShit.waveSpeed = 0.8;
|
||||
*/
|
||||
|
||||
// bg.shader = wiggleShit.shader;
|
||||
// fg.shader = wiggleShit.shader;
|
||||
|
||||
/*
|
||||
var waveSprite = new FlxEffectSprite(bg, [waveEffectBG]);
|
||||
var waveSpriteFG = new FlxEffectSprite(fg, [waveEffectFG]);
|
||||
|
||||
// Using scale since setGraphicSize() doesnt work???
|
||||
waveSprite.scale.set(6, 6);
|
||||
waveSpriteFG.scale.set(6, 6);
|
||||
waveSprite.setPosition(posX, posY);
|
||||
waveSpriteFG.setPosition(posX, posY);
|
||||
|
||||
waveSprite.scrollFactor.set(0.7, 0.8);
|
||||
waveSpriteFG.scrollFactor.set(0.9, 0.8);
|
||||
|
||||
// waveSprite.setGraphicSize(Std.int(waveSprite.width * 6));
|
||||
// waveSprite.updateHitbox();
|
||||
// waveSpriteFG.setGraphicSize(Std.int(fg.width * 6));
|
||||
// waveSpriteFG.updateHitbox();
|
||||
|
||||
add(waveSprite);
|
||||
add(waveSpriteFG);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultCamZoom = 0.9;
|
||||
|
@ -439,6 +508,8 @@ class PlayState extends MusicBeatState
|
|||
gfVersion = 'gf-christmas';
|
||||
case 'school':
|
||||
gfVersion = 'gf-pixel';
|
||||
case 'schoolEvil':
|
||||
gfVersion = 'gf-pixel';
|
||||
}
|
||||
|
||||
if (curStage == 'limo')
|
||||
|
@ -446,14 +517,12 @@ class PlayState extends MusicBeatState
|
|||
|
||||
gf = new Character(400, 130, gfVersion);
|
||||
gf.scrollFactor.set(0.95, 0.95);
|
||||
add(gf);
|
||||
|
||||
// Shitty layering but whatev it works LOL
|
||||
if (curStage == 'limo')
|
||||
add(limo);
|
||||
|
||||
dad = new Character(100, 100, SONG.player2);
|
||||
add(dad);
|
||||
|
||||
var camPos:FlxPoint = new FlxPoint(dad.getGraphicMidpoint().x, dad.getGraphicMidpoint().y);
|
||||
|
||||
|
@ -485,10 +554,13 @@ class PlayState extends MusicBeatState
|
|||
dad.x += 150;
|
||||
dad.y += 360;
|
||||
camPos.set(dad.getGraphicMidpoint().x + 300, dad.getGraphicMidpoint().y);
|
||||
case 'spirit':
|
||||
dad.x -= 150;
|
||||
dad.y += 100;
|
||||
camPos.set(dad.getGraphicMidpoint().x + 300, dad.getGraphicMidpoint().y);
|
||||
}
|
||||
|
||||
boyfriend = new Boyfriend(770, 450, SONG.player1);
|
||||
add(boyfriend);
|
||||
|
||||
// REPOSITIONING PER STAGE
|
||||
switch (curStage)
|
||||
|
@ -507,12 +579,29 @@ class PlayState extends MusicBeatState
|
|||
boyfriend.x += 320;
|
||||
dad.y -= 80;
|
||||
case 'school':
|
||||
boyfriend.x += 200;
|
||||
boyfriend.y += 220;
|
||||
gf.x += 180;
|
||||
gf.y += 300;
|
||||
case 'schoolEvil':
|
||||
// trailArea.scrollFactor.set();
|
||||
|
||||
var evilTrail = new FlxTrail(dad, null, 4, 24, 0.3, 0.069);
|
||||
// evilTrail.changeValuesEnabled(false, false, false, false);
|
||||
// evilTrail.changeGraphic()
|
||||
add(evilTrail);
|
||||
// evilTrail.scrollFactor.set(1.1, 1.1);
|
||||
|
||||
boyfriend.x += 200;
|
||||
boyfriend.y += 220;
|
||||
gf.x += 180;
|
||||
gf.y += 300;
|
||||
}
|
||||
|
||||
add(gf);
|
||||
add(dad);
|
||||
add(boyfriend);
|
||||
|
||||
var doof:DialogueBox = new DialogueBox(false, dialogue);
|
||||
// doof.x += 70;
|
||||
// doof.y = FlxG.height * 0.5;
|
||||
|
@ -702,6 +791,11 @@ class PlayState extends MusicBeatState
|
|||
'weeb/pixelUI/set-pixel.png',
|
||||
'weeb/pixelUI/date-pixel.png'
|
||||
]);
|
||||
introAssets.set('schoolEvil', [
|
||||
'weeb/pixelUI/ready-pixel.png',
|
||||
'weeb/pixelUI/set-pixel.png',
|
||||
'weeb/pixelUI/date-pixel.png'
|
||||
]);
|
||||
|
||||
var introAlts:Array<String> = introAssets.get('default');
|
||||
var altSuffix:String = "";
|
||||
|
@ -725,7 +819,7 @@ class PlayState extends MusicBeatState
|
|||
ready.scrollFactor.set();
|
||||
ready.updateHitbox();
|
||||
|
||||
if (curStage == 'school')
|
||||
if (curStage.startsWith('school'))
|
||||
ready.setGraphicSize(Std.int(ready.width * daPixelZoom));
|
||||
|
||||
ready.screenCenter();
|
||||
|
@ -742,7 +836,7 @@ class PlayState extends MusicBeatState
|
|||
var set:FlxSprite = new FlxSprite().loadGraphic('assets/images/' + introAlts[1]);
|
||||
set.scrollFactor.set();
|
||||
|
||||
if (curStage == 'school')
|
||||
if (curStage.startsWith('school'))
|
||||
set.setGraphicSize(Std.int(set.width * daPixelZoom));
|
||||
|
||||
set.screenCenter();
|
||||
|
@ -759,7 +853,7 @@ class PlayState extends MusicBeatState
|
|||
var go:FlxSprite = new FlxSprite().loadGraphic('assets/images/' + introAlts[2]);
|
||||
go.scrollFactor.set();
|
||||
|
||||
if (curStage == 'school')
|
||||
if (curStage.startsWith('school'))
|
||||
go.setGraphicSize(Std.int(go.width * daPixelZoom));
|
||||
|
||||
go.updateHitbox();
|
||||
|
@ -945,6 +1039,43 @@ class PlayState extends MusicBeatState
|
|||
babyArrow.animation.add('confirm', [12, 16], 24, false);
|
||||
}
|
||||
|
||||
case 'schoolEvil':
|
||||
// ALL THIS IS COPY PASTED CUZ IM LAZY
|
||||
|
||||
babyArrow.loadGraphic('assets/images/weeb/pixelUI/arrows-pixels.png', true, 17, 17);
|
||||
babyArrow.animation.add('green', [6]);
|
||||
babyArrow.animation.add('red', [7]);
|
||||
babyArrow.animation.add('blue', [5]);
|
||||
babyArrow.animation.add('purplel', [4]);
|
||||
|
||||
babyArrow.setGraphicSize(Std.int(babyArrow.width * daPixelZoom));
|
||||
babyArrow.updateHitbox();
|
||||
babyArrow.antialiasing = false;
|
||||
|
||||
switch (Math.abs(i))
|
||||
{
|
||||
case 2:
|
||||
babyArrow.x += Note.swagWidth * 2;
|
||||
babyArrow.animation.add('static', [2]);
|
||||
babyArrow.animation.add('pressed', [6, 10], 12, false);
|
||||
babyArrow.animation.add('confirm', [14, 18], 12, false);
|
||||
case 3:
|
||||
babyArrow.x += Note.swagWidth * 3;
|
||||
babyArrow.animation.add('static', [3]);
|
||||
babyArrow.animation.add('pressed', [7, 11], 12, false);
|
||||
babyArrow.animation.add('confirm', [15, 19], 24, false);
|
||||
case 1:
|
||||
babyArrow.x += Note.swagWidth * 1;
|
||||
babyArrow.animation.add('static', [1]);
|
||||
babyArrow.animation.add('pressed', [5, 9], 12, false);
|
||||
babyArrow.animation.add('confirm', [13, 17], 24, false);
|
||||
case 0:
|
||||
babyArrow.x += Note.swagWidth * 0;
|
||||
babyArrow.animation.add('static', [0]);
|
||||
babyArrow.animation.add('pressed', [4, 8], 12, false);
|
||||
babyArrow.animation.add('confirm', [12, 16], 24, false);
|
||||
}
|
||||
|
||||
default:
|
||||
babyArrow.frames = FlxAtlasFrames.fromSparrow('assets/images/NOTE_assets.png', 'assets/images/NOTE_assets.xml');
|
||||
babyArrow.animation.addByPrefix('green', 'arrowUP');
|
||||
|
@ -1082,7 +1213,6 @@ class PlayState extends MusicBeatState
|
|||
trainFrameTiming = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// phillyCityLights.members[curLight].alpha -= (Conductor.crochet / 1000) * FlxG.elapsed;
|
||||
}
|
||||
|
||||
|
@ -1214,6 +1344,9 @@ class PlayState extends MusicBeatState
|
|||
case 'school':
|
||||
camFollow.x = boyfriend.getMidpoint().x - 200;
|
||||
camFollow.y = boyfriend.getMidpoint().y - 200;
|
||||
case 'schoolEvil':
|
||||
camFollow.x = boyfriend.getMidpoint().x - 200;
|
||||
camFollow.y = boyfriend.getMidpoint().y - 200;
|
||||
}
|
||||
|
||||
if (SONG.song.toLowerCase() == 'tutorial')
|
||||
|
@ -1507,7 +1640,7 @@ class PlayState extends MusicBeatState
|
|||
var pixelShitPart1:String = "";
|
||||
var pixelShitPart2:String = '';
|
||||
|
||||
if (curStage == 'school')
|
||||
if (curStage.startsWith('school'))
|
||||
{
|
||||
pixelShitPart1 = 'weeb/pixelUI/';
|
||||
pixelShitPart2 = '-pixel';
|
||||
|
@ -1530,7 +1663,7 @@ class PlayState extends MusicBeatState
|
|||
comboSpr.velocity.x += FlxG.random.int(1, 10);
|
||||
add(rating);
|
||||
|
||||
if (curStage != 'school')
|
||||
if (!curStage.startsWith('school'))
|
||||
{
|
||||
rating.setGraphicSize(Std.int(rating.width * 0.7));
|
||||
rating.antialiasing = true;
|
||||
|
@ -1560,7 +1693,7 @@ class PlayState extends MusicBeatState
|
|||
numScore.x = coolText.x + (43 * daLoop) - 90;
|
||||
numScore.y += 80;
|
||||
|
||||
if (curStage != 'school')
|
||||
if (!curStage.startsWith('school'))
|
||||
{
|
||||
numScore.antialiasing = true;
|
||||
numScore.setGraphicSize(Std.int(numScore.width * 0.5));
|
||||
|
@ -1795,7 +1928,7 @@ class PlayState extends MusicBeatState
|
|||
spr.animation.play('static');
|
||||
}
|
||||
|
||||
if (spr.animation.curAnim.name == 'confirm' && curStage != 'school')
|
||||
if (spr.animation.curAnim.name == 'confirm' && !curStage.startsWith('school'))
|
||||
{
|
||||
spr.centerOffsets();
|
||||
spr.offset.x -= 13;
|
||||
|
@ -2029,6 +2162,7 @@ class PlayState extends MusicBeatState
|
|||
|
||||
override function beatHit()
|
||||
{
|
||||
wiggleShit.update(Conductor.crochet);
|
||||
super.beatHit();
|
||||
|
||||
if (generatedMusic)
|
||||
|
|
133
source/WiggleEffect.hx
Normal file
133
source/WiggleEffect.hx
Normal file
|
@ -0,0 +1,133 @@
|
|||
package;
|
||||
|
||||
// STOLEN FROM HAXEFLIXEL DEMO LOL
|
||||
import flixel.system.FlxAssets.FlxShader;
|
||||
|
||||
enum WiggleEffectType
|
||||
{
|
||||
DREAMY;
|
||||
WAVY;
|
||||
HEAT_WAVE_HORIZONTAL;
|
||||
HEAT_WAVE_VERTICAL;
|
||||
FLAG;
|
||||
}
|
||||
|
||||
class WiggleEffect
|
||||
{
|
||||
public var shader(default, null):WiggleShader = new WiggleShader();
|
||||
public var effectType(default, set):WiggleEffectType = DREAMY;
|
||||
public var waveSpeed(default, set):Float = 0;
|
||||
public var waveFrequency(default, set):Float = 0;
|
||||
public var waveAmplitude(default, set):Float = 0;
|
||||
|
||||
public function new():Void
|
||||
{
|
||||
shader.uTime.value = [0];
|
||||
}
|
||||
|
||||
public function update(elapsed:Float):Void
|
||||
{
|
||||
shader.uTime.value[0] += elapsed;
|
||||
}
|
||||
|
||||
function set_effectType(v:WiggleEffectType):WiggleEffectType
|
||||
{
|
||||
effectType = v;
|
||||
shader.effectType.value = [WiggleEffectType.getConstructors().indexOf(Std.string(v))];
|
||||
return v;
|
||||
}
|
||||
|
||||
function set_waveSpeed(v:Float):Float
|
||||
{
|
||||
waveSpeed = v;
|
||||
shader.uSpeed.value = [waveSpeed];
|
||||
return v;
|
||||
}
|
||||
|
||||
function set_waveFrequency(v:Float):Float
|
||||
{
|
||||
waveFrequency = v;
|
||||
shader.uFrequency.value = [waveFrequency];
|
||||
return v;
|
||||
}
|
||||
|
||||
function set_waveAmplitude(v:Float):Float
|
||||
{
|
||||
waveAmplitude = v;
|
||||
shader.uWaveAmplitude.value = [waveAmplitude];
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
class WiggleShader extends FlxShader
|
||||
{
|
||||
@:glFragmentSource('
|
||||
#pragma header
|
||||
//uniform float tx, ty; // x,y waves phase
|
||||
uniform float uTime;
|
||||
|
||||
const int EFFECT_TYPE_DREAMY = 0;
|
||||
const int EFFECT_TYPE_WAVY = 1;
|
||||
const int EFFECT_TYPE_HEAT_WAVE_HORIZONTAL = 2;
|
||||
const int EFFECT_TYPE_HEAT_WAVE_VERTICAL = 3;
|
||||
const int EFFECT_TYPE_FLAG = 4;
|
||||
|
||||
uniform int effectType;
|
||||
|
||||
/**
|
||||
* How fast the waves move over time
|
||||
*/
|
||||
uniform float uSpeed;
|
||||
|
||||
/**
|
||||
* Number of waves over time
|
||||
*/
|
||||
uniform float uFrequency;
|
||||
|
||||
/**
|
||||
* How much the pixels are going to stretch over the waves
|
||||
*/
|
||||
uniform float uWaveAmplitude;
|
||||
|
||||
vec2 sineWave(vec2 pt)
|
||||
{
|
||||
float x = 0.0;
|
||||
float y = 0.0;
|
||||
|
||||
if (effectType == EFFECT_TYPE_DREAMY)
|
||||
{
|
||||
float offsetX = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude;
|
||||
pt.x += offsetX; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving
|
||||
}
|
||||
else if (effectType == EFFECT_TYPE_WAVY)
|
||||
{
|
||||
float offsetY = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude;
|
||||
pt.y += offsetY; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving
|
||||
}
|
||||
else if (effectType == EFFECT_TYPE_HEAT_WAVE_HORIZONTAL)
|
||||
{
|
||||
x = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude;
|
||||
}
|
||||
else if (effectType == EFFECT_TYPE_HEAT_WAVE_VERTICAL)
|
||||
{
|
||||
y = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude;
|
||||
}
|
||||
else if (effectType == EFFECT_TYPE_FLAG)
|
||||
{
|
||||
y = sin(pt.y * uFrequency + 10.0 * pt.x + uTime * uSpeed) * uWaveAmplitude;
|
||||
x = sin(pt.x * uFrequency + 5.0 * pt.y + uTime * uSpeed) * uWaveAmplitude;
|
||||
}
|
||||
|
||||
return vec2(pt.x + x, pt.y + y);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 uv = sineWave(openfl_TextureCoordv);
|
||||
gl_FragColor = texture2D(bitmap, uv);
|
||||
}')
|
||||
public function new()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue