PureColor shader

This commit is contained in:
Cameron Taylor 2021-12-07 22:34:01 -05:00
parent c58ee24579
commit df4788dcf4
2 changed files with 62 additions and 3 deletions

View file

@ -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<SongMenuItem>();
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();
});
}

View file

@ -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;
}
}