1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-23 15:26:06 +00:00

color swap shit in progress

This commit is contained in:
Cameron Taylor 2021-03-21 14:45:46 -04:00
parent c80d8cc09e
commit 75ed1d5231
5 changed files with 96 additions and 12 deletions

View file

@ -0,0 +1,56 @@
package;
import flixel.group.FlxGroup.FlxTypedGroup;
import shaderslmfao.ColorSwap;
class ColorpickSubstate extends MusicBeatSubstate
{
var curSelected:Int = 0;
var grpNotes:FlxTypedGroup<Note>;
public function new()
{
super();
grpNotes = new FlxTypedGroup<Note>();
add(grpNotes);
for (i in 0...4)
{
var note:Note = new Note(0, i);
note.x = (100 * i) + i;
note.screenCenter(Y);
grpNotes.add(note);
}
}
override function update(elapsed:Float)
{
if (controls.RIGHT_P)
curSelected += 1;
if (controls.LEFT_P)
curSelected -= 1;
if (curSelected < 0)
curSelected = grpNotes.members.length - 1;
if (curSelected >= grpNotes.members.length)
curSelected = 0;
if (controls.UP)
{
grpNotes.members[curSelected].colorSwap.update(elapsed * 0.3);
Note.arrowColors[curSelected] += elapsed * 0.3;
}
if (controls.DOWN)
{
grpNotes.members[curSelected].colorSwap.update(-elapsed * 0.3);
Note.arrowColors[curSelected] += -elapsed * 0.3;
}
super.update(elapsed);
}
}

View file

@ -28,6 +28,7 @@ class Note extends FlxSprite
public var sustainLength:Float = 0;
public var isSustainNote:Bool = false;
public var colorSwap:ColorSwap;
public var noteScore:Float = 1;
public static var swagWidth:Float = 160 * 0.7;
@ -36,6 +37,8 @@ class Note extends FlxSprite
public static var BLUE_NOTE:Int = 1;
public static var RED_NOTE:Int = 3;
public static var arrowColors:Array<Float> = [1, 1, 1, 1];
public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false)
{
super();
@ -105,10 +108,6 @@ class Note extends FlxSprite
updateHitbox();
antialiasing = true;
var colorSwap = new ColorSwap();
// shader = colorSwap.shader;
// colorSwap.colorToReplace = 0xFFF9393F;
// colorSwap.newColor = 0xFF00FF00;
@ -117,11 +116,15 @@ class Note extends FlxSprite
// replaceColor(0xFFC1C1C1, FlxColor.RED);
}
colorSwap = new ColorSwap();
shader = colorSwap.shader;
switch (noteData)
{
case 0:
x += swagWidth * 0;
animation.play('purpleScroll');
case 1:
x += swagWidth * 1;
animation.play('blueScroll');
@ -155,6 +158,7 @@ class Note extends FlxSprite
}
updateHitbox();
updateColors();
x -= width / 2;
@ -182,6 +186,11 @@ class Note extends FlxSprite
}
}
public function updateColors():Void
{
colorSwap.update(arrowColors[noteData]);
}
override function update(elapsed:Float)
{
super.update(elapsed);

View file

@ -8,7 +8,7 @@ import flixel.util.FlxColor;
class OptionsSubState extends MusicBeatSubstate
{
var textMenuItems:Array<String> = ['Master Volume', 'Sound Volume', 'Controls'];
var textMenuItems:Array<String> = ['Master Volume', 'Sound Volume', 'Controls', 'Colors'];
var selector:FlxSprite;
var curSelected:Int = 0;
@ -67,6 +67,9 @@ class OptionsSubState extends MusicBeatSubstate
{
switch (textMenuItems[curSelected])
{
case "Colors":
FlxG.state.closeSubState();
FlxG.state.openSubState(new ColorpickSubstate());
case "Controls":
FlxG.state.closeSubState();
FlxG.state.openSubState(new ControlsSubState());

View file

@ -42,7 +42,7 @@ class TitleState extends MusicBeatState
var lastBeat:Int = 0;
// var swagShader:ColorSwap;
var swagShader:ColorSwap;
override public function create():Void
{
@ -50,7 +50,7 @@ class TitleState extends MusicBeatState
polymod.Polymod.init({modRoot: "mods", dirs: ['introMod'], framework: OPENFL});
#end
// swagShader = new ColorSwap();
swagShader = new ColorSwap();
FlxG.sound.muteKeys = [ZERO];
@ -154,7 +154,7 @@ class TitleState extends MusicBeatState
logoBl.animation.play('bump');
logoBl.updateHitbox();
// logoBl.shader = swagShader.shader;
logoBl.shader = swagShader.shader;
// trace();
// logoBl.screenCenter();
@ -167,7 +167,7 @@ class TitleState extends MusicBeatState
gfDance.antialiasing = true;
add(gfDance);
// gfDance.shader = swagShader.shader;
gfDance.shader = swagShader.shader;
add(logoBl);
@ -333,6 +333,16 @@ class TitleState extends MusicBeatState
skipIntro();
}
if (controls.LEFT)
{
swagShader.update(-elapsed * 0.1);
}
if (controls.RIGHT)
{
swagShader.update(elapsed * 0.1);
}
super.update(elapsed);
}
@ -366,12 +376,12 @@ class TitleState extends MusicBeatState
}
}
var isRainbow:Bool = false;
override function beatHit()
{
super.beatHit();
// swagShader.update(FlxG.random.float(0.1, 0.7));
logoBl.animation.play('bump', true);
danceLeft = !danceLeft;

View file

@ -9,16 +9,20 @@ class ColorSwap
public var colorToReplace(default, set):FlxColor;
public var newColor(default, set):FlxColor;
public var daTime(default, set):Float;
public var hueShit:Float = 0;
public function new():Void
{
shader = new ColorSwapShader();
shader.uTime.value = [0];
shader.money.value = [0];
}
public function update(elapsed:Float):Void
{
shader.uTime.value[0] += elapsed;
hueShit += elapsed;
// trace(shader.money.value[0]);
}
function set_colorToReplace(color:FlxColor):FlxColor
@ -46,8 +50,8 @@ class ColorSwapShader extends FlxShader
@:glFragmentSource('
#pragma header
uniform float uTime;
uniform float money;
vec3 normalizeColor(vec3 color)
{
@ -86,6 +90,8 @@ class ColorSwapShader extends FlxShader
swagColor[0] += uTime;
// swagColor[1] += uTime;
// money += swagColor[0];
color = vec4(hsv2rgb(vec3(swagColor[0], swagColor[1], swagColor[2])), swagColor[3]);
gl_FragColor = color;