hue shifting in progress

This commit is contained in:
Cameron Taylor 2023-08-23 05:33:52 -04:00 committed by EliteMasterEric
parent 20d13f56ac
commit b20cb27f82
5 changed files with 278 additions and 2 deletions

2
assets

@ -1 +1 @@
Subproject commit bc7e486ba4cf52e55893daa951e58b37059b0adb
Subproject commit cb481d79891707029a7f10975ce0d392c56f244a

View file

@ -32,7 +32,7 @@
"name": "flxanimate",
"type": "git",
"dir": null,
"ref": "a913635",
"ref": "37fd4ed45011063a38fdfe9bb6091671b3ac6c17",
"url": "https://github.com/ninjamuffin99/flxanimate"
},
{

View file

@ -0,0 +1,112 @@
package funkin.freeplayStuff;
import flixel.group.FlxSpriteGroup;
import funkin.graphics.adobeanimate.FlxAtlasSprite;
import funkin.shaderslmfao.HSVShader;
class DifficultyStars extends FlxSpriteGroup
{
/**
* Internal handler var for difficulty... ranges from 0... to 15
* 0 is 1 star... 15 is 0 stars!
*/
var curDifficulty(default, set):Int = 0;
/**
* Range between 0 and 15
*/
public var difficulty(default, set):Int = 1;
var stars:FlxAtlasSprite;
var flames:FreeplayFlames;
var hsvShader:HSVShader;
public function new(x:Float, y:Float)
{
super(x, y);
hsvShader = new HSVShader();
flames = new FreeplayFlames(0, 0);
add(flames);
stars = new FlxAtlasSprite(0, 0, Paths.animateAtlas("freeplay/freeplayStars"));
stars.anim.play("diff stars");
add(stars);
stars.shader = hsvShader;
for (memb in flames.members)
memb.shader = hsvShader;
FlxG.debugger.addTrackerProfile(new TrackerProfile(HSVShader, ["hue", "saturation", "value"]));
FlxG.debugger.track(hsvShader);
FlxG.debugger.addTrackerProfile(new TrackerProfile(DifficultyStars, ["difficulty"]));
FlxG.debugger.track(this);
}
override function update(elapsed:Float):Void
{
super.update(elapsed);
// "loops" the current animation
// for clarity, the animation file looks like
// frame : stars
// 0-99: 1 star
// 100-199: 2 stars
// ......
// 1300-1499: 15 stars
// 1500 : 0 stars
if (curDifficulty < 15 && stars.anim.curFrame >= (curDifficulty + 1) * 100)
{
stars.anim.play("diff stars", true, false, curDifficulty * 100);
}
}
function set_difficulty(value:Int):Int
{
difficulty = value;
if (difficulty <= 0)
{
difficulty = 0;
curDifficulty = 15;
}
else if (difficulty <= 15)
{
difficulty = value;
curDifficulty = difficulty - 1;
}
else
{
difficulty = 15;
curDifficulty = difficulty - 1;
}
if (difficulty > 10) flames.flameCount = difficulty - 10;
else
flames.flameCount = 0;
return difficulty;
}
function set_curDifficulty(value:Int):Int
{
curDifficulty = value;
if (curDifficulty == 15)
{
stars.anim.play("diff stars", true, false, 1500);
stars.anim.pause();
}
else
{
stars.anim.curFrame = Std.int(curDifficulty * 100);
stars.anim.play("diff stars", true, false, curDifficulty * 100);
}
return curDifficulty;
}
}

View file

@ -0,0 +1,120 @@
package funkin.freeplayStuff;
import flixel.group.FlxSpriteGroup;
import flixel.FlxSprite;
import flixel.util.FlxTimer;
class FreeplayFlames extends FlxSpriteGroup
{
var flameX(default, set):Float = 917;
var flameY(default, set):Float = 103;
var flameSpreadX(default, set):Float = 29;
var flameSpreadY(default, set):Float = 6;
public var flameCount(default, set):Int = 0;
var flameTimer:Float = 0.25;
public function new(x:Float, y:Float)
{
super(x, y);
for (i in 0...5)
{
var flame:FlxSprite = new FlxSprite(flameX + (flameSpreadX * i), flameY + (flameSpreadY * i));
flame.frames = Paths.getSparrowAtlas("freeplay/freeplayFlame");
flame.animation.addByPrefix("flame", "fire loop", FlxG.random.int(23, 25), false);
flame.animation.play("flame");
flame.visible = false;
flameCount = 0;
// sets the loop... maybe better way to do this lol!
flame.animation.finishCallback = function(_) {
flame.animation.play("flame", true, false, 2);
};
add(flame);
}
FlxG.debugger.addTrackerProfile(new TrackerProfile(FreeplayFlames, ["flameTimer"]));
FlxG.debugger.track(this);
}
var properPositions:Bool = false;
override public function update(elapsed:Float):Void
{
super.update(elapsed);
// doesn't work in create()/new() for some reason
// so putting it here bwah!
if (!properPositions)
{
setFlamePositions();
properPositions = true;
}
}
function set_flameCount(value:Int):Int
{
this.flameCount = value;
var visibleCount:Int = 0;
for (i in 0...5)
{
if (members[i] == null) continue;
var flame:FlxSprite = members[i];
if (i < flameCount)
{
if (!flame.visible)
{
new FlxTimer().start(flameTimer * visibleCount, function(_) {
flame.animation.play("flame", true);
flame.visible = true;
});
visibleCount++;
}
}
else
{
flame.visible = false;
}
}
return this.flameCount;
}
function setFlamePositions()
{
for (i in 0...5)
{
var flame:FlxSprite = members[i];
flame.x = flameX + (flameSpreadX * i);
flame.y = flameY + (flameSpreadY * i);
}
}
function set_flameX(value:Float):Float
{
this.flameX = value;
setFlamePositions();
return this.flameX;
}
function set_flameY(value:Float):Float
{
this.flameY = value;
setFlamePositions();
return this.flameY;
}
function set_flameSpreadX(value:Float):Float
{
this.flameSpreadX = value;
setFlamePositions();
return this.flameSpreadX;
}
function set_flameSpreadY(value:Float):Float
{
this.flameSpreadY = value;
setFlamePositions();
return this.flameSpreadY;
}
}

View file

@ -0,0 +1,44 @@
package funkin.shaderslmfao;
import flixel.addons.display.FlxRuntimeShader;
import funkin.Paths;
import openfl.utils.Assets;
class HSVShader extends FlxRuntimeShader
{
public var hue(default, set):Float;
public var saturation(default, set):Float;
public var value(default, set):Float;
public function new()
{
super(Assets.getText(Paths.frag('hsv')));
hue = 1;
saturation = 1;
value = 1;
}
function set_hue(value:Float):Float
{
this.setFloat('hue', value);
this.hue = value;
return this.hue;
}
function set_saturation(value:Float):Float
{
this.setFloat('sat', value);
this.saturation = value;
return this.saturation;
}
function set_value(value:Float):Float
{
this.setFloat('val', value);
this.value = value;
return this.value;
}
}