From df4788dcf40155fbc1cc21d8d866ecdefa7c150f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 7 Dec 2021 22:34:01 -0500 Subject: [PATCH] PureColor shader --- source/FreeplayState.hx | 17 +++++++++-- source/shaderslmfao/PureColor.hx | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 source/shaderslmfao/PureColor.hx diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 3e1e58005..719178bfd 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -28,6 +28,7 @@ import freeplayStuff.SongMenuItem; import lime.app.Future; import lime.utils.Assets; import shaderslmfao.AngleMask; +import shaderslmfao.PureColor; import shaderslmfao.StrokeShader; using StringTools; @@ -198,7 +199,7 @@ class FreeplayState extends MusicBeatSubstate grpCapsules = new FlxTypedGroup(); add(grpCapsules); - grpDifficulties = new FlxSpriteGroup(-300, 100); + grpDifficulties = new FlxSpriteGroup(-300, 80); add(grpDifficulties); grpDifficulties.add(new FlxSprite().loadGraphic(Paths.image('freeplay/freeplayEasy'))); @@ -232,8 +233,8 @@ class FreeplayState extends MusicBeatSubstate { FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut}); - add(new DifficultySelector(20, grpDifficulties.y, false, controls)); - add(new DifficultySelector(325, grpDifficulties.y, true, controls)); + add(new DifficultySelector(20, grpDifficulties.y - 10, false, controls)); + add(new DifficultySelector(325, grpDifficulties.y - 10, true, controls)); var animShit:ComboCounter = new ComboCounter(100, 300, 1000000); // add(animShit); @@ -591,8 +592,10 @@ class FreeplayState extends MusicBeatSubstate curShit.visible = true; curShit.offset.y += 5; + curShit.alpha = 0.5; new FlxTimer().start(1 / 24, function(swag) { + curShit.alpha = 1; curShit.updateHitbox(); }); } @@ -664,6 +667,7 @@ class FreeplayState extends MusicBeatSubstate class DifficultySelector extends FlxSprite { var controls:Controls; + var whiteShader:PureColor; public function new(x:Float, y:Float, flipped:Bool, controls:Controls) { @@ -675,6 +679,10 @@ class DifficultySelector extends FlxSprite animation.addByPrefix('shine', "arrow pointer loop", 24); animation.play('shine'); + whiteShader = new PureColor(FlxColor.WHITE); + + shader = whiteShader; + flipX = flipped; } @@ -692,8 +700,11 @@ class DifficultySelector extends FlxSprite { offset.y -= 5; + whiteShader.colorSet = true; + new FlxTimer().start(2 / 24, function(tmr) { + whiteShader.colorSet = false; updateHitbox(); }); } diff --git a/source/shaderslmfao/PureColor.hx b/source/shaderslmfao/PureColor.hx new file mode 100644 index 000000000..774df767a --- /dev/null +++ b/source/shaderslmfao/PureColor.hx @@ -0,0 +1,48 @@ +package shaderslmfao; + +import flixel.system.FlxAssets.FlxShader; +import flixel.util.FlxColor; + +class PureColor extends FlxShader +{ + public var col(default, set):FlxColor; + public var colorSet(default, set):Bool; + + function set_colorSet(bol:Bool):Bool + { + colSet.value = [bol]; + + return bol; + } + + function set_col(val:FlxColor):FlxColor + { + funnyColor.value = [val.red, val.green, val.blue, val.alpha]; + + return val; + } + + @:glFragmentSource(' + #pragma header + + uniform vec4 funnyColor; + uniform bool colSet; + + void main() + { + vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv); + + if (color.a > 0.0 && colSet) + color = vec4(funnyColor.r, funnyColor.g, funnyColor.b, color.a); + + gl_FragColor = color; + } + ') + public function new(colr:FlxColor) + { + super(); + + this.col = colr; + this.colorSet = false; + } +}