From 0b22165408c0b831e6bdc8512182851583b1c94b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:24:08 +0200 Subject: [PATCH 1/4] =?UTF-8?q?why=20did=20NOBODY=20tell=20me=20fast=20car?= =?UTF-8?q?s=20arent=20working=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/data/stages/limo.hx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/assets/data/stages/limo.hx b/assets/data/stages/limo.hx index 0116d55a..d9a58d3c 100644 --- a/assets/data/stages/limo.hx +++ b/assets/data/stages/limo.hx @@ -1,39 +1,43 @@ var fastCarCanDrive:Bool = true; -function create() { +function create() resetFastCar(); -} -function update(elapsed:Float) { + +function update(elapsed:Float) +{ if (!fastCarCanDrive && fastCar.x > 2000) { resetFastCar(); fastCarCanDrive = true; } + var offset = Math.sin(curBeatFloat / 4) * Math.cos(curBeatFloat / 16) * 85; + // back limo drive if (Options.lowMemoryMode) { - bgLimo.frameOffset.x = Math.sin(curBeatFloat / 4) * Math.cos(curBeatFloat / 16) * 85; + bgLimo.frameOffset.x = offset; } else { for(e in [bgLimo, dancer1, dancer2, dancer3, dancer4, dancer5]) { - e.frameOffset.x = Math.sin(curBeatFloat / 4) * Math.cos(curBeatFloat / 16) * 85; + e.frameOffset.x = offset; } } } -function beatHit(curBeat:Int) { +function beatHit(curBeat:Int) if (FlxG.random.bool(10) && fastCarCanDrive) fastCarDrive(); -} - -function resetFastCar() { +function resetFastCar() +{ fastCar.x = -12600; fastCar.y = FlxG.random.int(140, 250); fastCar.velocity.x = 0; + fastCar.moves = false; fastCarCanDrive = true; } function fastCarDrive() { FlxG.sound.play(Paths.soundRandom('carPass', 0, 1), 0.7); - fastCar.velocity.x = (FlxG.random.int(170, 220) / FlxG.elapsed) * 3; + fastCar.velocity.x = FlxG.random.int(170, 220) * 60 * 3; + fastCar.moves = true; fastCarCanDrive = false; } \ No newline at end of file From 4a6a8498f9844dd40bc53a77b67632b278da6b7e Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Sat, 21 Sep 2024 18:33:19 +0200 Subject: [PATCH 2/4] Small byte optimizations --- source/funkin/backend/shaders/FunkinShader.hx | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/source/funkin/backend/shaders/FunkinShader.hx b/source/funkin/backend/shaders/FunkinShader.hx index f8d66fae..d9a8ddd8 100644 --- a/source/funkin/backend/shaders/FunkinShader.hx +++ b/source/funkin/backend/shaders/FunkinShader.hx @@ -439,22 +439,22 @@ uniform bool hasTransform; uniform bool hasColorTransform; vec4 applyFlixelEffects(vec4 color) { - if (!hasTransform) { + if(!hasTransform) { return color; } - if (color.a == 0.0) { + if(color.a == 0.0) { return vec4(0.0, 0.0, 0.0, 0.0); } - if (!hasColorTransform) { + if(!hasColorTransform) { return color * openfl_Alphav; } color.rgb = color.rgb / color.a; color = clamp(openfl_ColorOffsetv + (color * openfl_ColorMultiplierv), 0.0, 1.0); - if (color.a > 0.0) { + if(color.a > 0.0) { return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); } return vec4(0.0, 0.0, 0.0, 0.0); @@ -504,11 +504,9 @@ uniform vec2 openfl_TextureSize;"; public static final vertBody:String = "openfl_Alphav = openfl_Alpha; openfl_TextureCoordv = openfl_TextureCoord; -if (openfl_HasColorTransform) { - +if(openfl_HasColorTransform) { openfl_ColorMultiplierv = openfl_ColorMultiplier; openfl_ColorOffsetv = openfl_ColorOffset / 255.0; - } gl_Position = openfl_Matrix * openfl_Position;"; @@ -521,14 +519,12 @@ attribute vec4 colorMultiplier; attribute vec4 colorOffset; uniform bool hasColorTransform; -void main(void) -{ +void main(void) { #pragma body openfl_Alphav = openfl_Alpha * alpha; - if (hasColorTransform) - { + if(hasColorTransform) { openfl_ColorOffsetv = colorOffset / 255.0; openfl_ColorMultiplierv = colorMultiplier; } @@ -538,8 +534,7 @@ void main(void) // TODO: camera stuff public static final defaultFragmentSource:String = "#pragma header -void main(void) -{ +void main(void) { gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv); }"; } From 53ecf67d67dd26e6f8fe1066239521c9bcda9ba1 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Sat, 21 Sep 2024 18:48:18 +0200 Subject: [PATCH 3/4] Add the stuffs to the default vertex body and header --- source/funkin/backend/shaders/FunkinShader.hx | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/source/funkin/backend/shaders/FunkinShader.hx b/source/funkin/backend/shaders/FunkinShader.hx index d9a8ddd8..0b282ffb 100644 --- a/source/funkin/backend/shaders/FunkinShader.hx +++ b/source/funkin/backend/shaders/FunkinShader.hx @@ -483,9 +483,7 @@ vec4 textureCam(sampler2D bitmap, vec2 pos) { return flixel_texture2D(bitmap, camToOg(pos)); }"; - public static final fragBody:String = "vec4 color = flixel_texture2D (bitmap, openfl_TextureCoordv); - gl_FragColor = color; -"; + public static final fragBody:String = "gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv);"; public static final vertHeader:String = "attribute float openfl_Alpha; attribute vec4 openfl_ColorMultiplier; attribute vec4 openfl_ColorOffset; @@ -499,7 +497,12 @@ varying vec2 openfl_TextureCoordv; uniform mat4 openfl_Matrix; uniform bool openfl_HasColorTransform; -uniform vec2 openfl_TextureSize;"; +uniform vec2 openfl_TextureSize; + +attribute float alpha; +attribute vec4 colorMultiplier; +attribute vec4 colorOffset; +uniform bool hasColorTransform;"; public static final vertBody:String = "openfl_Alphav = openfl_Alpha; openfl_TextureCoordv = openfl_TextureCoord; @@ -509,33 +512,26 @@ if(openfl_HasColorTransform) { openfl_ColorOffsetv = openfl_ColorOffset / 255.0; } +openfl_Alphav = openfl_Alpha * alpha; + +if(hasColorTransform) { + openfl_ColorOffsetv = colorOffset / 255.0; + openfl_ColorMultiplierv = colorMultiplier; +} + gl_Position = openfl_Matrix * openfl_Position;"; public static final defaultVertexSource:String = "#pragma header -attribute float alpha; -attribute vec4 colorMultiplier; -attribute vec4 colorOffset; -uniform bool hasColorTransform; - void main(void) { #pragma body - - openfl_Alphav = openfl_Alpha * alpha; - - if(hasColorTransform) { - openfl_ColorOffsetv = colorOffset / 255.0; - openfl_ColorMultiplierv = colorMultiplier; - } }"; - - // TODO: camera stuff public static final defaultFragmentSource:String = "#pragma header void main(void) { - gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv); + #pragma body }"; } From 3ef5ba31f648cd0f1b90ea8b0eab416731a95edf Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Sun, 22 Sep 2024 15:14:35 +0200 Subject: [PATCH 4/4] Small change --- commandline/Main.hx | 2 +- commandline/commands/{Update.hx => Setup.hx} | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) rename commandline/commands/{Update.hx => Setup.hx} (97%) diff --git a/commandline/Main.hx b/commandline/Main.hx index 8c2f9301..1b5b01b8 100644 --- a/commandline/Main.hx +++ b/commandline/Main.hx @@ -12,7 +12,7 @@ class Main { { names: ["setup"], doc: "Setups (or updates) all libraries required for the engine.", - func: Update.main, + func: Setup.main, dDoc: [ "Usage: setup", "", diff --git a/commandline/commands/Update.hx b/commandline/commands/Setup.hx similarity index 97% rename from commandline/commands/Update.hx rename to commandline/commands/Setup.hx index 0d39d27c..4e97e989 100644 --- a/commandline/commands/Update.hx +++ b/commandline/commands/Setup.hx @@ -6,7 +6,7 @@ import sys.io.File; import sys.io.Process; import sys.FileSystem; -class Update { +class Setup { private static function recursiveDelete(path:String) { for(file in FileSystem.readDirectory(path)) { var p = '$path/$file'; @@ -54,10 +54,10 @@ class Update { case "lib" | "git": var lib:Library = { name: libNode.att.name, - type: libNode.name + type: libNode.name, + skipDeps: libNode.has.skipDeps ? libNode.att.skipDeps == "true" : false, }; if (libNode.has.global) lib.global = libNode.att.global; - if (libNode.has.skipDeps) lib.skipDeps = libNode.att.skipDeps; switch (lib.type) { case "lib": if (libNode.has.version) lib.version = libNode.att.version; @@ -139,7 +139,7 @@ class Update { case INSTALL: var lib:Library = event.data; var globalSuffix:Null = lib.global == "true" ? " --global" : ""; - var skipDeps = lib.skipDeps == "true" ? " --skip-dependencies" : ""; + var skipDeps = lib.skipDeps ? " --skip-dependencies" : ""; var commandPrefix = commandSuffix + globalSuffix + skipDeps;// + " --no-timeout"; switch(lib.type) { case "lib": @@ -276,8 +276,8 @@ class Update { typedef Library = { var name:String; var type:String; + var skipDeps:Bool; var ?global:String; - var ?skipDeps:String; var ?recursive:String; var ?version:String; var ?ref:String;