Skip to content

Commit

Permalink
Shaders and fixed a bug
Browse files Browse the repository at this point in the history
After this you will probably see less commits since I want to take a break from this
  • Loading branch information
CamLikesKirby committed Jun 18, 2024
1 parent ec899bd commit d2d001a
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 98 deletions.
4 changes: 2 additions & 2 deletions source/Alphabet.hx
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ class AlphaCharacter extends FlxSprite
animation.play(letter);
if (invert)
{
#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
this.shader = new InvertShader();
#end
}
}

updateHitbox();
Expand Down
9 changes: 5 additions & 4 deletions source/CharacterSelectState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,15 @@ class CharacterSelectState extends MusicBeatState
{
bg.loadGraphic(Paths.image('backgrounds/void/redsky', 'shared'));

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {

bgShader = new Shaders.GlitchEffect();
bgShader.waveAmplitude = 0.1;
bgShader.waveFrequency = 5;
bgShader.waveSpeed = 2;

bg.shader = bgShader.shader;
#end
}
}
add(bg);

Expand Down Expand Up @@ -472,12 +473,12 @@ class CharacterSelectState extends MusicBeatState
}
override public function update(elapsed:Float):Void
{
#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
if (bgShader != null)
{
bgShader.shader.uTime.value[0] += elapsed;
}
#end
}
Conductor.songPosition = FlxG.sound.music.time;

var controlSet:Array<Bool> = [controls.LEFT_P, controls.DOWN_P, controls.UP_P, controls.RIGHT_P];
Expand Down
16 changes: 8 additions & 8 deletions source/DialogueBox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ class DialogueBox extends FlxSpriteGroup

override function update(elapsed:Float)
{
#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
if (curshader != null)
{
curshader.shader.uTime.value[0] += elapsed;
}
#end
}
dropText.text = swagDialogue.text;
switch (curCharacter)
{
Expand Down Expand Up @@ -462,15 +462,15 @@ class DialogueBox extends FlxSpriteGroup
shad.waveSpeed = 1;
shad.shader.uTime.value[0] = new flixel.math.FlxRandom().float(-100000,100000);
shad.shader.uampmul.value[0] = 1;*/
#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
PlayState.screenshader.Enabled = true;
#end
}
case 'undistort':
#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
PlayState.screenshader.Enabled = false;
#end
}
case 'distortbg':
#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
var shad:Shaders.DistortBGEffect = new Shaders.DistortBGEffect();
curshader = shad;
shad.waveAmplitude = 0.1;
Expand All @@ -481,7 +481,7 @@ class DialogueBox extends FlxSpriteGroup
portraitLeft.shader = shad.shader;
portraitRight.shader = shad.shader;
}
#end
}
case 'setfont_normal':
dropText.font = 'Comic Sans MS Bold';
swagDialogue.font = 'Comic Sans MS Bold';
Expand Down
8 changes: 4 additions & 4 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ class FreeplayState extends MusicBeatState
bg.color = FlxColor.multiply(bg.color, FlxColor.fromRGB(50, 50, 50));
add(bg);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
bgShader = new Shaders.GlitchEffect();
bgShader.waveAmplitude = 0.1;
bgShader.waveFrequency = 5;
bgShader.waveSpeed = 2;

bg.shader = bgShader.shader;
#end
}
defColor = bg.color;
}
else
Expand Down Expand Up @@ -655,12 +655,12 @@ class FreeplayState extends MusicBeatState
{
super.update(elapsed);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
if (bgShader != null)
{
bgShader.shader.uTime.value[0] += elapsed;
}
#end
}
cantEarn = FlxG.save.data.botplay || FlxG.save.data.practiceMode || FlxG.save.data.oppM || FlxG.save.data.randomNotes || rPNT[FlxG.save.data.randomNoteTypes] != 'Off' || FlxG.save.data.bothSides;

if (cantEarn && cantEarnText != null) {
Expand Down
8 changes: 4 additions & 4 deletions source/GameOverPolygonizedSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ class GameOverPolygonizedSubState extends MusicBeatSubstate
bg.setGraphicSize(Std.int(bg.width * 1.5));
add(bg);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
voidShader = new Shaders.GlitchEffect();
voidShader.waveAmplitude = 0.1;
voidShader.waveFrequency = 5;
voidShader.waveSpeed = 2;

bg.shader = voidShader.shader;
#end
}

Conductor.songPosition = 0;

Expand Down Expand Up @@ -146,9 +146,9 @@ class GameOverPolygonizedSubState extends MusicBeatSubstate
{
super.update(elapsed);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
voidShader.shader.uTime.value[0] += elapsed;
#end
}

if (controls.ACCEPT)
{
Expand Down
12 changes: 6 additions & 6 deletions source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ class MainMenuState extends MusicBeatState
bg.color = FlxColor.multiply(bg.color, FlxColor.fromRGB(50, 50, 50));
add(bg);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
voidShader = new Shaders.GlitchEffect();
voidShader.waveAmplitude = 0.1;
voidShader.waveFrequency = 5;
voidShader.waveSpeed = 2;

bg.shader = voidShader.shader;
#end
}

magenta = new FlxSprite(-600, -200).loadGraphic(bg.graphic);
magenta.scrollFactor.set();
Expand All @@ -180,9 +180,9 @@ class MainMenuState extends MusicBeatState
magenta.color = FlxColor.multiply(0xFFfd719b, FlxColor.fromRGB(50, 50, 50));
add(magenta);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
magenta.shader = voidShader.shader;
#end
}
}
else
{
Expand Down Expand Up @@ -323,12 +323,12 @@ class MainMenuState extends MusicBeatState

override function update(elapsed:Float)
{
#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
if (voidShader != null)
{
voidShader.shader.uTime.value[0] += elapsed;
}
#end
}
if (FlxG.sound.music.volume < 0.8)
{
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
Expand Down
12 changes: 8 additions & 4 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class OptionsMenu extends MusicBeatState
menuBG.antialiasing = false;
add(menuBG);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
bgShader = new Shaders.GlitchEffect();
bgShader.waveAmplitude = 0.1;
bgShader.waveFrequency = 5;
bgShader.waveSpeed = 2;

menuBG.shader = bgShader.shader;
#end
}
}
else
{
Expand Down Expand Up @@ -106,6 +106,7 @@ class OptionsMenu extends MusicBeatState
+ "\n" + (FlxG.save.data.vanScoreSys ? "New Score System ON" : "New Score System OFF")
+ "\n" + (FlxG.save.data.vanMissSys ? "New Miss System ON" : "New Miss System OFF")
+ "\n" + (FlxG.save.data.middleScroll ? "Middlescroll ON" : "Middlescroll OFF")
+ "\n" + (FlxG.save.data.wantShaders ? "Shaders ON" : "Shaders OFF")
);

grpControls = new FlxTypedGroup<Alphabet>();
Expand Down Expand Up @@ -134,12 +135,12 @@ class OptionsMenu extends MusicBeatState
{
super.update(elapsed);

#if SHADERS_ENABLED
if (FlxG.save.data.wantShaders) {
if (bgShader != null)
{
bgShader.shader.uTime.value[0] += elapsed;
}
#end
}

if (controls.BACK)
{
Expand Down Expand Up @@ -254,6 +255,9 @@ class OptionsMenu extends MusicBeatState
case 20:
FlxG.save.data.middleScroll = !FlxG.save.data.middleScroll;
updateGroupControls(FlxG.save.data.middleScroll ? 'Middlescroll ON' : 'Middlescroll OFF', 12, 'Vertical');
case 21:
FlxG.save.data.wantShaders = !FlxG.save.data.wantShaders;
updateGroupControls(FlxG.save.data.wantShaders ? 'Shaders ON' : 'Shaders OFF', 12, 'Vertical');
}
}

Expand Down
Loading

0 comments on commit d2d001a

Please sign in to comment.