From 275d4f6f5dbf5112938c8c10a4330887b3ce2033 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 12 Feb 2024 15:11:46 -0500 Subject: [PATCH 1/5] bigger FlxLightPuzzle (#328) --- Arcade/FlxLightPuzzle/Project.xml | 2 +- Arcade/FlxLightPuzzle/source/Main.hx | 2 ++ Arcade/FlxLightPuzzle/source/MenuState.hx | 20 ++++++----- Arcade/FlxLightPuzzle/source/PlayState.hx | 14 ++++---- Arcade/FlxLightPuzzle/source/Template.hx | 4 +-- Arcade/FlxLightPuzzle/source/UILayer.hx | 41 +++++++++++++---------- Arcade/FlxLightPuzzle/source/WinState.hx | 6 ++-- 7 files changed, 50 insertions(+), 39 deletions(-) diff --git a/Arcade/FlxLightPuzzle/Project.xml b/Arcade/FlxLightPuzzle/Project.xml index 71490c71b..e16c004b0 100644 --- a/Arcade/FlxLightPuzzle/Project.xml +++ b/Arcade/FlxLightPuzzle/Project.xml @@ -16,7 +16,7 @@ - + diff --git a/Arcade/FlxLightPuzzle/source/Main.hx b/Arcade/FlxLightPuzzle/source/Main.hx index efa0e2d46..5fa4f15c7 100644 --- a/Arcade/FlxLightPuzzle/source/Main.hx +++ b/Arcade/FlxLightPuzzle/source/Main.hx @@ -1,5 +1,6 @@ package; +import lime.app.Application; import flixel.FlxGame; import openfl.display.Sprite; @@ -8,6 +9,7 @@ class Main extends Sprite public function new() { super(); + addChild(new FlxGame(0, 0, PlayState)); } } diff --git a/Arcade/FlxLightPuzzle/source/MenuState.hx b/Arcade/FlxLightPuzzle/source/MenuState.hx index c2f49c5dc..15dec4aed 100644 --- a/Arcade/FlxLightPuzzle/source/MenuState.hx +++ b/Arcade/FlxLightPuzzle/source/MenuState.hx @@ -20,24 +20,30 @@ class MenuState extends FlxSubState override public function create():Void { - title = new FlxText(50, 10, 512 - 50, "FlxLightPuzzle", 20); + title = new FlxText(50 * 2, 10 * 2, (512 - 50) * 2, "FlxLightPuzzle", 20 * 2); title.color = FlxColor.WHITE; title.alignment = "center"; add(title); // barsHorizontal.png from Kenney.nl were colored to make them more appropriate for this game - playRYB = new FlxSprite(300, 72 - 25, AssetPaths.ryb__png); + playRYB = new FlxSprite(300 * 2, (72 - 25) * 2, AssetPaths.ryb__png); + playRYB.setGraphicSize(Std.int(playRYB.width * 2)); + playRYB.updateHitbox(); FlxMouseEvent.add(playRYB, null, onSelect, onMOver, onMOut, false, true, false); FlxMouseEvent.setMouseClickCallback(playRYB, onSelect); add(playRYB); - playRGB = new FlxSprite(300, 144 - 25, AssetPaths.rgb__png); + playRGB = new FlxSprite(300 * 2, (144 - 25) * 2, AssetPaths.rgb__png); + playRGB.setGraphicSize(Std.int(playRGB.width * 2)); + playRGB.updateHitbox(); FlxMouseEvent.add(playRGB, null, onSelect, onMOver, onMOut, false, true, false); FlxMouseEvent.setMouseClickCallback(playRGB, onSelect); add(playRGB); - playCMY = new FlxSprite(300, 216 - 25, AssetPaths.cmy__png); + playCMY = new FlxSprite(300 * 2, (216 - 25) * 2, AssetPaths.cmy__png); + playCMY.setGraphicSize(Std.int(playCMY.width * 2)); + playCMY.updateHitbox(); FlxMouseEvent.add(playCMY, null, onSelect, onMOver, onMOut, false, true, false); FlxMouseEvent.setMouseClickCallback(playCMY, onSelect); add(playCMY); @@ -84,13 +90,11 @@ class MenuState extends FlxSubState function onMOver(target:FlxSprite):Void { // make the buttons more noticeable by expanding them on mouse over - target.scale.x = 1.25; - target.scale.y = 1.25; + target.setGraphicSize(Std.int(target.width * 1.25)); } function onMOut(target:FlxSprite):Void { - target.scale.x = 1; - target.scale.y = 1; + target.setGraphicSize(Std.int(target.width)); } } diff --git a/Arcade/FlxLightPuzzle/source/PlayState.hx b/Arcade/FlxLightPuzzle/source/PlayState.hx index cd3e201ab..e0b4a7f9a 100644 --- a/Arcade/FlxLightPuzzle/source/PlayState.hx +++ b/Arcade/FlxLightPuzzle/source/PlayState.hx @@ -46,14 +46,14 @@ class PlayState extends FlxState ui = new UILayer(resetLevel); // the player is a high-tech triangle - player = new FlxSprite(75, 144); - player.makeGraphic(26, 26, FlxColor.TRANSPARENT, true); - FlxSpriteUtil.drawTriangle(player, 0, 0, 26, FlxColor.WHITE); - player.offset.set(13, 13); + player = new FlxSprite(75 * 2, 144 * 2); + player.makeGraphic(26 * 2, 26 * 2, FlxColor.TRANSPARENT, true); + FlxSpriteUtil.drawTriangle(player, 0, 0, 26 * 2, FlxColor.WHITE); + player.offset.set(13 * 2, 13 * 2); player.pixelPerfectRender = false; - player.antialiasing = true; + player.antialiasing = false; - playerPosition = FlxPoint.get(75, 144); + playerPosition = FlxPoint.get(75 * 2, 144 * 2); currLevelIndex = -1; blockLevelReset = false; @@ -172,7 +172,7 @@ class PlayState extends FlxState if (currLevelIndex >= numLevels) { // win the game - var endCircle = new Circle(FlxPoint.get(300, 144), 350, Color.WHITE); + var endCircle = new Circle(FlxPoint.get(300 * 2, 144 * 2), 350 * 2, Color.WHITE); game.drawCircle(endCircle, 1, 4.32); openSubState(new WinState()); diff --git a/Arcade/FlxLightPuzzle/source/Template.hx b/Arcade/FlxLightPuzzle/source/Template.hx index 51c848ae9..ad73bb15d 100644 --- a/Arcade/FlxLightPuzzle/source/Template.hx +++ b/Arcade/FlxLightPuzzle/source/Template.hx @@ -54,7 +54,7 @@ class Template for (targetData in targetsData) { var params = targetData.split(" "); - targetsDefault.push(new Circle(FlxPoint.get(Std.parseFloat(params[0]), Std.parseFloat(params[1])), Std.parseFloat(params[2]), + targetsDefault.push(new Circle(FlxPoint.get(Std.parseFloat(params[0]) * 2, Std.parseFloat(params[1]) * 2), Std.parseFloat(params[2]) * 2, getColorFromData(params[3]))); } @@ -70,7 +70,7 @@ class Template for (i in 0...numVerts) { - verts.push(FlxPoint.get(Std.parseFloat(params[2 * i]), Std.parseFloat(params[2 * i + 1]))); + verts.push(FlxPoint.get(Std.parseFloat(params[2 * i]) * 2, Std.parseFloat(params[2 * i + 1]) * 2)); } if (numVerts == 2) diff --git a/Arcade/FlxLightPuzzle/source/UILayer.hx b/Arcade/FlxLightPuzzle/source/UILayer.hx index ae3dd0cc3..7fe4baef6 100644 --- a/Arcade/FlxLightPuzzle/source/UILayer.hx +++ b/Arcade/FlxLightPuzzle/source/UILayer.hx @@ -34,23 +34,25 @@ class UILayer extends FlxSpriteGroup // a black background helps the UI buttons stand out bg = new FlxSprite(); - bg.makeGraphic(250, FlxG.height, FlxColor.BLACK); // should this change based on the selected color palette? + bg.makeGraphic(250 * 2, FlxG.height, FlxColor.BLACK); // should this change based on the selected color palette? FlxMouseEvent.add(bg, null, null, onPanelOver, onPanelOut, true, true, true); // pixel-perfect because we will be using a clipRect and need the extra checks add(bg); - ammo = new FlxSprite(5, 223); - ammo.makeGraphic(40, 60, 0x0, true); + ammo = new FlxSprite(5 * 2, 223 * 2); + ammo.makeGraphic(40 * 2, 60 * 2, 0x0, true); add(ammo); // the original art files from Kenney.nl are in multiple pngs: I combined several using an image editor to make a spritesheet that I can easily load as an animation // tools like TexturePacker do all that for you plus more: check out the TexturePackerDemo too! - var mute = new FlxSprite(0, 69); + var mute = new FlxSprite(0, 69 * 2); mute.loadGraphic(AssetPaths.music__png, true, 50, 50); + mute.setGraphicSize(Std.int(mute.width * 2)); + mute.updateHitbox(); mute.animation.add("unmuted", [0], 0, false); mute.animation.add("muted", [1], 0, false); mute.animation.play("unmuted"); @@ -73,22 +75,27 @@ class UILayer extends FlxSpriteGroup add(fullscreen); */ - var restart = new FlxSprite(0, 69 + 100); + var restart = new FlxSprite(0, (69 + 100) * 2); restart.loadGraphic(AssetPaths.return__png, false); + restart.setGraphicSize(Std.int(restart.width * 2)); + restart.updateHitbox(); FlxMouseEvent.add(restart, null, onRestart, onMOver, onMOut, true, true, false); add(restart); - source = new FlxText(100, 50, 150, "Click for the source code", 14); + source = new FlxText(100 * 2, 50 * 2, 150 * 2, "Click for the source code", 14 * 2); FlxMouseEvent.add(source, null, onSource, onMOver, onMOut, true, true, false); add(source); - patreon = new FlxSprite(125, 125, AssetPaths.haxeflixel__png); // "click to learn more"? + patreon = new FlxSprite(125 * 2, 125 * 2, AssetPaths.haxeflixel__png); // "click to learn more"? + patreon.antialiasing = true; + patreon.setGraphicSize(Std.int(patreon.width * 2)); + patreon.updateHitbox(); FlxMouseEvent.add(patreon, null, onPatreon, onMOver, onMOut, true, true, false); add(patreon); - credits = new FlxText(60, 216, 180, "Made by MSGhero for HaxeFlixel\nArt from Kenney.nl\nWaltz in G minor by Strimlarn87", 8); + credits = new FlxText(60 * 2, 216 * 2, 180 * 2, "Made by MSGhero for HaxeFlixel\nArt from Kenney.nl\nWaltz in G minor by Strimlarn87", 8 * 2); credits.alignment = "center"; FlxMouseEvent.add(credits, null, onCredits, onMOver, onMOut, true, true, false); add(credits); @@ -97,8 +104,8 @@ class UILayer extends FlxSpriteGroup // the UI panel will expand when moused over, and that will be controlled by a clipRect // which will hide the right side of the panel until the left is moused over - clipRect = new FlxRect(0, 0, 50, FlxG.height); - bg.width = 50; + clipRect = new FlxRect(0, 0, 50 * 2, FlxG.height); + bg.width = 50 * 2; } public function setAmmo(remainingAmmo:Array):Void @@ -107,7 +114,7 @@ class UILayer extends FlxSpriteGroup // you could also manage separate sprites, each being one unit of ammo (photons?) var color:FlxColor = 0x0; - var rect = new Rectangle(0, 0, 40, 20); + var rect = new Rectangle(0, 0, 40 * 2, 20 * 2); for (i in 0...3) { @@ -116,7 +123,7 @@ class UILayer extends FlxSpriteGroup else color = FlxColor.BLACK; - rect.y = 40 - i * 20; + rect.y = 80 - i * 40; ammo.pixels.fillRect(rect, color); } @@ -176,7 +183,7 @@ class UILayer extends FlxSpriteGroup function onPanelOver(target:FlxSprite):Void { - clipRect.width = bg.width = 250; + clipRect.width = bg.width = 250 * 2; clipRect = clipRect; // you have to set the clipRect for it to update, just changing a property doesn't do anything source.visible = patreon.visible = credits.visible = true; // we don't want these responding to mouse clicks when covered up, so we have to manually set their visibility @@ -184,7 +191,7 @@ class UILayer extends FlxSpriteGroup function onPanelOut(target:FlxSprite):Void { - clipRect.width = bg.width = 50; + clipRect.width = bg.width = 50 * 2; clipRect = clipRect; source.visible = patreon.visible = credits.visible = false; @@ -218,14 +225,12 @@ class UILayer extends FlxSpriteGroup function onMOver(target:FlxSprite):Void { - target.scale.x = 1.25; - target.scale.y = 1.25; + target.setGraphicSize(Std.int(target.width * 1.25)); } function onMOut(target:FlxSprite):Void { - target.scale.x = 1; - target.scale.y = 1; + target.setGraphicSize(Std.int(target.width)); } override function get_width():Float diff --git a/Arcade/FlxLightPuzzle/source/WinState.hx b/Arcade/FlxLightPuzzle/source/WinState.hx index 1210a6ef9..1ac394460 100644 --- a/Arcade/FlxLightPuzzle/source/WinState.hx +++ b/Arcade/FlxLightPuzzle/source/WinState.hx @@ -17,12 +17,12 @@ class WinState extends FlxSubState { var bg = ColorMaps.defaultColorMap[Color.WHITE] == FlxColor.BLACK ? FlxColor.WHITE : FlxColor.BLACK; // if the background is black, we want white text, and vice-versa - winMessage = new FlxText(256, 40, 250, + winMessage = new FlxText(256 * 2, 40 * 2, 250 * 2, "Want more?\n\nYou can copy the code to make more levels or change it however you want.\n\n" + "This project is open source and released under MIT license thanks to HaxeFlixel supporters.\n\n" + "Grab the code and become a HaxeFlixel supporter to help make more cool open-source demos like this.", - 14); - winMessage.setFormat(null, 12, bg); + 14 * 2); + winMessage.setFormat(null, 12 * 2, bg); winMessage.alignment = "center"; // delay to match up with the expanding circle background From 493fe254013ea22dafd40e9531ef7f997e38fb33 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 27 Feb 2024 21:25:31 -0800 Subject: [PATCH 2/5] Flixel 6 compatibility (#331) * remove warnings (for flixel 6) * fix demos for flixel 6 --- .vscode/settings.json | 92 ++++++++++- Arcade/Breakout/source/PlayState.hx | 2 +- Arcade/FlxLightPuzzle/source/Color.hx | 3 +- Arcade/FlxPongApi/source/MenuState.hx | 4 +- Arcade/FlxPongApi/source/PlayState.hx | 4 +- Arcade/FlxTeroids/source/MenuState.hx | 2 +- Arcade/FlxTeroids/source/PlayState.hx | 2 +- Arcade/MinimalistTD/source/MenuState.hx | 2 +- Arcade/MinimalistTD/source/PlayState.hx | 2 +- Effects/BlendModeShaders/source/Main.hx | 1 - Effects/BlendModeShaders/source/PlayState.hx | 19 +-- .../{openfl8 => }/blends/ColorBurnShader.hx | 2 +- .../{openfl8 => }/blends/HardMixShader.hx | 2 +- .../{openfl8 => }/blends/LightenShader.hx | 2 +- .../{openfl8 => }/blends/LinearDodgeShader.hx | 2 +- .../{openfl8 => }/blends/MultiplyShader.hx | 2 +- .../{openfl8 => }/blends/VividLightShader.hx | 2 +- .../{openfl8 => }/effects/BlendModeEffect.hx | 10 +- .../{openfl8 => }/effects/ColorSwapEffect.hx | 24 +-- .../{openfl8 => }/effects/ShutterEffect.hx | 28 ++-- .../{openfl8 => }/effects/WiggleEffect.hx | 14 +- .../source/openfl3/blends/ColorBurnShader.hx | 40 ----- .../source/openfl3/blends/HardMixShader.hx | 59 ------- .../source/openfl3/blends/LightenShader.hx | 30 ---- .../openfl3/blends/LinearDodgeShader.hx | 38 ----- .../source/openfl3/blends/MultiplyShader.hx | 30 ---- .../source/openfl3/blends/VividLightShader.hx | 50 ------ .../source/openfl3/effects/BlendModeEffect.hx | 32 ---- .../source/openfl3/effects/ColorSwapEffect.hx | 116 ------------- .../source/openfl3/effects/ShutterEffect.hx | 154 ------------------ .../source/openfl3/effects/WiggleEffect.hx | 129 --------------- .../DynamicShadows/source/PlayStateShader.hx | 8 +- Effects/Filters/source/PlayState.hx | 54 +++--- .../source/{openfl8 => filters}/Grain.hx | 2 +- .../source/{openfl8 => filters}/Hq2x.hx | 2 +- .../source/{openfl8 => filters}/Scanline.hx | 2 +- .../source/{openfl8 => filters}/Tiltshift.hx | 2 +- Effects/Filters/source/openfl3/Grain.hx | 149 ----------------- Effects/Filters/source/openfl3/Hq2x.hx | 33 ---- Effects/Filters/source/openfl3/Scanline.hx | 22 --- Effects/Filters/source/openfl3/Tiltshift.hx | 89 ---------- Effects/FlxTrailArea/source/BlurState.hx | 2 +- Effects/FlxTrailArea/source/ParticleState.hx | 2 +- Effects/Transitions/source/MenuState.hx | 63 +++---- Effects/Transitions/source/MenuStateB.hx | 4 +- Features/FlxNapeTilemap/source/Main.hx | 1 - .../source/{states => }/PlayState.hx | 4 +- Features/Replay/source/PlayState.hx | 2 +- Features/ScaleModes/source/PlayState.hx | 3 +- .../source/generate/GenerateState.hx | 2 +- Other/BSPMapGen/source/play/PlayState.hx | 2 +- Other/Calculator/source/State.hx | 1 - Other/FlxCollisions/source/PlayState.hx | 2 +- Other/FlxCollisions/source/PlayState2.hx | 2 +- Other/FlxCollisions/source/PlayState3.hx | 2 +- Other/FrameCollections/source/PlayState.hx | 2 +- .../PixelPerfectCollision/source/PlayState.hx | 1 - .../source/entities/Character.hx | 4 +- Platformers/Mode/source/MenuState.hx | 4 +- Platformers/Mode/source/PlayState.hx | 4 +- Platformers/Mode/source/Player.hx | 2 +- Platformers/Mode/source/VictoryState.hx | 2 +- Platformers/ProjectJumper/source/MenuState.hx | 2 +- Platformers/ProjectJumper/source/PlayState.hx | 2 +- Platformers/Revenge/source/EndState.hx | 2 +- Platformers/Revenge/source/MenuState.hx | 2 +- Platformers/Revenge/source/PlayState.hx | 2 +- Tutorials/TurnBasedRPG/source/CombatHUD.hx | 2 +- Tutorials/TurnBasedRPG/source/Enemy.hx | 4 +- .../TurnBasedRPG/source/GameOverState.hx | 11 +- Tutorials/TurnBasedRPG/source/HUD.hx | 2 +- Tutorials/TurnBasedRPG/source/MenuState.hx | 4 +- Tutorials/TurnBasedRPG/source/OptionsState.hx | 14 +- Tutorials/TurnBasedRPG/source/PlayState.hx | 4 +- Tutorials/TurnBasedRPG/source/Player.hx | 2 +- .../FlxBitmapText/source/PlayState.hx | 4 +- .../RPGInterface/source/State_Battle.hx | 7 +- .../RPGInterface/source/State_CodeTest.hx | 7 +- .../RPGInterface/source/State_DefaultTest.hx | 7 +- .../RPGInterface/source/State_SaveMenu.hx | 7 +- .../RPGInterface/source/State_TestMenu.hx | 7 +- .../RPGInterface/source/State_Title.hx | 17 +- UserInterface/Tooltips/source/State_Demo.hx | 11 +- UserInterface/Tooltips/source/State_Demo2.hx | 4 +- .../Tooltips/source/State_DemoCode.hx | 48 +++--- 85 files changed, 343 insertions(+), 1202 deletions(-) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/ColorBurnShader.hx (97%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/HardMixShader.hx (98%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/LightenShader.hx (95%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/LinearDodgeShader.hx (97%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/MultiplyShader.hx (95%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/VividLightShader.hx (97%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/BlendModeEffect.hx (96%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/ColorSwapEffect.hx (98%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/ShutterEffect.hx (98%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/WiggleEffect.hx (98%) delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx rename Effects/Filters/source/{openfl8 => filters}/Grain.hx (99%) rename Effects/Filters/source/{openfl8 => filters}/Hq2x.hx (98%) rename Effects/Filters/source/{openfl8 => filters}/Scanline.hx (96%) rename Effects/Filters/source/{openfl8 => filters}/Tiltshift.hx (99%) delete mode 100644 Effects/Filters/source/openfl3/Grain.hx delete mode 100644 Effects/Filters/source/openfl3/Hq2x.hx delete mode 100644 Effects/Filters/source/openfl3/Scanline.hx delete mode 100644 Effects/Filters/source/openfl3/Tiltshift.hx rename Features/FlxNapeTilemap/source/{states => }/PlayState.hx (97%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 390ca28a4..bc601fbda 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,94 @@ { "search.exclude": { - "**/export/**/*.hx": true + "**/export/**": true }, "[haxe]": { - "editor.formatOnSave": true - } + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modifications" + }, + "lime.projectFile": "Tutorials/TurnBasedRPG/Project.xml", + "haxecheckstyle.sourceFolders": [ + "Arcade/Breakout/source", + "Arcade/Flappybalt/source", + "Arcade/Flixius/source", + "Arcade/FlxInvaders/source", + "Arcade/FlxLightPuzzle/source", + "Arcade/FlxPongApi/source", + "Arcade/FlxSnake/source", + "Arcade/FlxTeroids/source", + "Arcade/MinimalistTD/source", + "Editors/FlxPexParser/source", + "Editors/FlxSpine/source", + "Editors/TexturePackerAtlas/source", + "Effects/BlendModes/source", + "Effects/BlendModesShaders/source", + "Effects/DynamicShadows/source", + "Effects/Filters/source", + "Effects/FloodFill/source", + "Effects/FlxBloom/source", + "Effects/FlxBlur/source", + "Effects/FlxClothSprite/source", + "Effects/FlxEffectSprite/source", + "Effects/FlxFloodFill/source", + "Effects/FlxSimplex/source", + "Effects/FlxSkewedSprite/source", + "Effects/FlxSpriteFilters/source", + "Effects/FlxTrailArea/source", + "Effects/FlxTween/source", + "Effects/MosaicEffect/source", + "Effects/Parallax/source", + "Effects/PostProcess/source", + "Effects/Transitions/source", + "Features/CollisionAndGrouping/source", + "Features/Colors/source", + "Features/FlxCamera/source", + "Features/FlxFSM/source", + "Features/FlxNape/source", + "Features/FlxTerrain/source", + "Features/FlxTilemap/source", + "Features/FlxPieDial/source", + "Features/FlxScene/source", + "Features/FlxShape/source", + "Features/FlxSound/source", + "Features/HeatmapPathfinding/source", + "Features/Particles/source", + "Features/Pathfinding/source", + "Features/Replay/source", + "Features/ScaleModes/source", + "Features/SetTileProperties/source", + "Features/SplitScreen/source", + "Features/SubState/source", + "Features/Tilemap/source", + "Graphics/FlxAsepriteUtils/source", + "Input/FlxAccelerometer/source", + "Input/FlxAction/source", + "Input/FlxMouseEvent/source", + "Input/GamepadTest/source", + "Input/GridMovement/source", + "Input/Multitouch/source", + "Other/BSPMapGen/source", + "Other/Calculator/source", + "Other/FlxAsyncLoop/source", + "Other/FlxAtlas/source", + "Other/FrameCollections/source", + "Other/FlxBunnyMark/source", + "Other/FlxRandom/source", + "Other/NeonVector/source", + "Other/PixelPerfectCollision/source", + "Platformers/EZPlatformer/source", + "Platformers/FlipRotationAnimationTiles/source", + "Platformers/FlxCaveGenerator/source", + "Platformers/FlxTilemapExt/source", + "Platformers/Mode/source", + "Platformers/ProjectJumper/source", + "Platformers/Revenge/source", + "Tutorials/TurnBasedRPG/source", + "UserInterface/Cursor/source", + "UserInterface/FileBrowser/source", + "UserInterface/FlxBitmapText/source", + "UserInterface/FlxTextFormat/source", + "UserInterface/FlxTypeText/source", + "UserInterface/RPGInterface/source", + "UserInterface/Tooltips/source" + ] } \ No newline at end of file diff --git a/Arcade/Breakout/source/PlayState.hx b/Arcade/Breakout/source/PlayState.hx index 2d8a3631e..0d89ecdb2 100644 --- a/Arcade/Breakout/source/PlayState.hx +++ b/Arcade/Breakout/source/PlayState.hx @@ -115,7 +115,7 @@ class PlayState extends FlxState { if (swipe.distance > 100) { - if ((swipe.angle < 10 && swipe.angle > -10) || (swipe.angle > 170 || swipe.angle < -170)) + if ((swipe.degrees < 10 && swipe.degrees > -10) || (swipe.degrees > 170 || swipe.degrees < -170)) { FlxG.resetState(); } diff --git a/Arcade/FlxLightPuzzle/source/Color.hx b/Arcade/FlxLightPuzzle/source/Color.hx index 18a0b6fd2..f05b8d156 100644 --- a/Arcade/FlxLightPuzzle/source/Color.hx +++ b/Arcade/FlxLightPuzzle/source/Color.hx @@ -5,8 +5,7 @@ package; * Abstract Int so that colors can be easily combined using the | (or) operator. * @author MSGHero */ -@:enum -abstract Color(Int) from Int to Int +enum abstract Color(Int) from Int to Int { var MIRROR = 0x01 << 0; var RED = 0x01 << 1; diff --git a/Arcade/FlxPongApi/source/MenuState.hx b/Arcade/FlxPongApi/source/MenuState.hx index 1c9bcd573..8f92d0e3c 100644 --- a/Arcade/FlxPongApi/source/MenuState.hx +++ b/Arcade/FlxPongApi/source/MenuState.hx @@ -335,13 +335,13 @@ class MenuState extends FlxState function colorCallback(Name:String):Void { Reg.genColors(); - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } #end function playCallback(Name:String):Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } function hfCallback(Name:String):Void diff --git a/Arcade/FlxPongApi/source/PlayState.hx b/Arcade/FlxPongApi/source/PlayState.hx index d712516d1..4b9703d54 100644 --- a/Arcade/FlxPongApi/source/PlayState.hx +++ b/Arcade/FlxPongApi/source/PlayState.hx @@ -93,7 +93,7 @@ class PlayState extends FlxState } if (FlxG.keys.justPressed.ESCAPE) { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } #end @@ -150,6 +150,6 @@ class PlayState extends FlxState function endGame(f:FlxTimer):Void { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } } diff --git a/Arcade/FlxTeroids/source/MenuState.hx b/Arcade/FlxTeroids/source/MenuState.hx index 44fcaa83b..a07097eee 100644 --- a/Arcade/FlxTeroids/source/MenuState.hx +++ b/Arcade/FlxTeroids/source/MenuState.hx @@ -23,7 +23,7 @@ class MenuState extends FlxState { if (FlxG.keys.justReleased.SPACE) { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } } diff --git a/Arcade/FlxTeroids/source/PlayState.hx b/Arcade/FlxTeroids/source/PlayState.hx index aa632d882..825c553b7 100644 --- a/Arcade/FlxTeroids/source/PlayState.hx +++ b/Arcade/FlxTeroids/source/PlayState.hx @@ -88,7 +88,7 @@ class PlayState extends FlxState // Escape to the menu if (FlxG.keys.pressed.ESCAPE) { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } super.update(elapsed); diff --git a/Arcade/MinimalistTD/source/MenuState.hx b/Arcade/MinimalistTD/source/MenuState.hx index 0a3af8181..783592ba7 100644 --- a/Arcade/MinimalistTD/source/MenuState.hx +++ b/Arcade/MinimalistTD/source/MenuState.hx @@ -65,7 +65,7 @@ class MenuState extends FlxState */ function startGame():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } override public function update(elapsed:Float):Void diff --git a/Arcade/MinimalistTD/source/PlayState.hx b/Arcade/MinimalistTD/source/PlayState.hx index 20b2fa0e4..e1e28c01a 100644 --- a/Arcade/MinimalistTD/source/PlayState.hx +++ b/Arcade/MinimalistTD/source/PlayState.hx @@ -306,7 +306,7 @@ class PlayState extends FlxState if (FlxG.keys.justReleased.ESCAPE) { FlxG.sound.destroy(true); - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } if (FlxG.keys.justReleased.N) { diff --git a/Effects/BlendModeShaders/source/Main.hx b/Effects/BlendModeShaders/source/Main.hx index 354843e36..efa0e2d46 100644 --- a/Effects/BlendModeShaders/source/Main.hx +++ b/Effects/BlendModeShaders/source/Main.hx @@ -1,7 +1,6 @@ package; import flixel.FlxGame; -import openfl.Lib; import openfl.display.Sprite; class Main extends Sprite diff --git a/Effects/BlendModeShaders/source/PlayState.hx b/Effects/BlendModeShaders/source/PlayState.hx index 9c6b7864a..db5e97b49 100644 --- a/Effects/BlendModeShaders/source/PlayState.hx +++ b/Effects/BlendModeShaders/source/PlayState.hx @@ -5,17 +5,10 @@ import flixel.FlxSprite; import flixel.FlxState; import flixel.util.FlxColor; #if shaders_supported -#if (openfl >= "8.0.0") -import openfl8.blends.*; -import openfl8.effects.*; -import openfl8.effects.WiggleEffect.WiggleEffectType; -import openfl8.effects.BlendModeEffect.BlendModeShader; -#else -import openfl3.blends.*; -import openfl3.effects.*; -import openfl3.effects.WiggleEffect.WiggleEffectType; -import openfl3.effects.BlendModeEffect.BlendModeShader; -#end +import blends.*; +import effects.*; +import effects.WiggleEffect.WiggleEffectType; +import effects.BlendModeEffect.BlendModeShader; import flixel.util.FlxTimer; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; @@ -26,7 +19,7 @@ import openfl.filters.ShaderFilter; import flixel.text.FlxText; #end -@:enum abstract LogoColor(FlxColor) to FlxColor +enum abstract LogoColor(FlxColor) to FlxColor { static var LIST(default, null) = [RED, BLUE, YELLOW, CYAN, GREEN]; var RED = 0xff3366; @@ -126,7 +119,7 @@ class PlayState extends FlxState color.alphaFloat = 0.5; var effect = new BlendModeEffect(effects[blendEffect], color); - FlxG.camera.setFilters([new ShaderFilter(cast effect.shader)]); + FlxG.camera.filters = [new ShaderFilter(cast effect.shader)]; } function createShutterEffect():Void diff --git a/Effects/BlendModeShaders/source/openfl8/blends/ColorBurnShader.hx b/Effects/BlendModeShaders/source/blends/ColorBurnShader.hx similarity index 97% rename from Effects/BlendModeShaders/source/openfl8/blends/ColorBurnShader.hx rename to Effects/BlendModeShaders/source/blends/ColorBurnShader.hx index 41906b851..783a3c03d 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/ColorBurnShader.hx +++ b/Effects/BlendModeShaders/source/blends/ColorBurnShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/HardMixShader.hx b/Effects/BlendModeShaders/source/blends/HardMixShader.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/blends/HardMixShader.hx rename to Effects/BlendModeShaders/source/blends/HardMixShader.hx index 3d93a31e8..060c09040 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/HardMixShader.hx +++ b/Effects/BlendModeShaders/source/blends/HardMixShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/LightenShader.hx b/Effects/BlendModeShaders/source/blends/LightenShader.hx similarity index 95% rename from Effects/BlendModeShaders/source/openfl8/blends/LightenShader.hx rename to Effects/BlendModeShaders/source/blends/LightenShader.hx index 09a4fc52f..8fb15c170 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/LightenShader.hx +++ b/Effects/BlendModeShaders/source/blends/LightenShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/LinearDodgeShader.hx b/Effects/BlendModeShaders/source/blends/LinearDodgeShader.hx similarity index 97% rename from Effects/BlendModeShaders/source/openfl8/blends/LinearDodgeShader.hx rename to Effects/BlendModeShaders/source/blends/LinearDodgeShader.hx index 4ba901b3e..b76a494a8 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/LinearDodgeShader.hx +++ b/Effects/BlendModeShaders/source/blends/LinearDodgeShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/MultiplyShader.hx b/Effects/BlendModeShaders/source/blends/MultiplyShader.hx similarity index 95% rename from Effects/BlendModeShaders/source/openfl8/blends/MultiplyShader.hx rename to Effects/BlendModeShaders/source/blends/MultiplyShader.hx index 3e4fe0d42..b2bc8299a 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/MultiplyShader.hx +++ b/Effects/BlendModeShaders/source/blends/MultiplyShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/VividLightShader.hx b/Effects/BlendModeShaders/source/blends/VividLightShader.hx similarity index 97% rename from Effects/BlendModeShaders/source/openfl8/blends/VividLightShader.hx rename to Effects/BlendModeShaders/source/blends/VividLightShader.hx index 06e9d5ddc..cac0d3368 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/VividLightShader.hx +++ b/Effects/BlendModeShaders/source/blends/VividLightShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/effects/BlendModeEffect.hx b/Effects/BlendModeShaders/source/effects/BlendModeEffect.hx similarity index 96% rename from Effects/BlendModeShaders/source/openfl8/effects/BlendModeEffect.hx rename to Effects/BlendModeShaders/source/effects/BlendModeEffect.hx index b438a6e39..9c6f8a0aa 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/BlendModeEffect.hx +++ b/Effects/BlendModeShaders/source/effects/BlendModeEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.util.FlxColor; import openfl.display.ShaderParameter; @@ -11,24 +11,24 @@ typedef BlendModeShader = class BlendModeEffect { public var shader(default, null):BlendModeShader; - + @:isVar public var color(default, set):FlxColor; - + public function new(shader:BlendModeShader, color:FlxColor):Void { shader.uBlendColor.value = []; this.shader = shader; this.color = color; } - + function set_color(color:FlxColor):FlxColor { shader.uBlendColor.value[0] = color.redFloat; shader.uBlendColor.value[1] = color.greenFloat; shader.uBlendColor.value[2] = color.blueFloat; shader.uBlendColor.value[3] = color.alphaFloat; - + return this.color = color; } } diff --git a/Effects/BlendModeShaders/source/openfl8/effects/ColorSwapEffect.hx b/Effects/BlendModeShaders/source/effects/ColorSwapEffect.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/effects/ColorSwapEffect.hx rename to Effects/BlendModeShaders/source/effects/ColorSwapEffect.hx index b521f8635..85acabd2d 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/ColorSwapEffect.hx +++ b/Effects/BlendModeShaders/source/effects/ColorSwapEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.util.FlxColor; import flixel.system.FlxAssets.FlxShader; @@ -9,22 +9,22 @@ class ColorSwapEffect * The instance of the actual shader class */ public var shader(default, null):ColorSwapShader; - + /** * The color to replace with another */ public var colorToReplace(default, set):FlxColor; - + /** * The desired new color */ public var newColor(default, set):FlxColor; - + /** * Activates/Deactivates the shader */ public var isShaderActive(default, set):Bool; - + public function new():Void { shader = new ColorSwapShader(); @@ -32,33 +32,33 @@ class ColorSwapEffect shader.colorOld.value = []; shader.colorNew.value = []; } - + function set_isShaderActive(value:Bool):Bool { isShaderActive = value; shader.shaderIsActive.value[0] = value; return value; } - + function set_colorToReplace(color:FlxColor):FlxColor { colorToReplace = color; - + shader.colorOld.value[0] = color.red; shader.colorOld.value[1] = color.green; shader.colorOld.value[2] = color.blue; - + return color; } - + function set_newColor(color:FlxColor):FlxColor { newColor = color; - + shader.colorNew.value[0] = color.red; shader.colorNew.value[1] = color.green; shader.colorNew.value[2] = color.blue; - + return color; } } diff --git a/Effects/BlendModeShaders/source/openfl8/effects/ShutterEffect.hx b/Effects/BlendModeShaders/source/effects/ShutterEffect.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/effects/ShutterEffect.hx rename to Effects/BlendModeShaders/source/effects/ShutterEffect.hx index 100e8d921..53297ee52 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/ShutterEffect.hx +++ b/Effects/BlendModeShaders/source/effects/ShutterEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.FlxG; import flixel.system.FlxAssets.FlxShader; @@ -7,28 +7,28 @@ class ShutterEffect { public static inline var SHUTTER_TARGET_FLXSPRITE:Int = 0; public static inline var SHUTTER_TARGET_FLXCAMERA:Int = 1; - + public var shutterTargetMode(default, set):Int = 0; - + /** * The instance of the actual shader class */ public var shader(default, null):ShutterShader; - + /** * Size of the circle or "shutter" */ public var radius(default, set):Float; - + /** * Center point of the "shutter" */ public var shutterCenterX(default, set):Float; - + public var shutterCenterY(default, set):Float; - + public var isActive(default, set):Bool; - + public function new():Void { shader = new ShutterShader(); @@ -39,40 +39,40 @@ class ShutterEffect shutterTargetMode = SHUTTER_TARGET_FLXSPRITE; radius = 0; } - + function setResolution():Void { shader.uResolution.value = [FlxG.width, FlxG.height]; } - + function set_shutterTargetMode(v:Int):Int { shutterTargetMode = v; shader.shutterTargetMode.value = [shutterTargetMode]; return v; } - + function set_isActive(v:Bool):Bool { isActive = v; shader.shaderIsActive.value = [isActive]; return v; } - + function set_radius(v:Float):Float { radius = (v <= 0.0 ? 0.0 : v); shader.uCircleRadius.value = [radius]; return v; } - + function set_shutterCenterX(v:Float):Float { shutterCenterX = v; shader.centerPtX.value = [v]; return v; } - + function set_shutterCenterY(v:Float):Float { shutterCenterY = v; diff --git a/Effects/BlendModeShaders/source/openfl8/effects/WiggleEffect.hx b/Effects/BlendModeShaders/source/effects/WiggleEffect.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/effects/WiggleEffect.hx rename to Effects/BlendModeShaders/source/effects/WiggleEffect.hx index f53894aba..23e730c2d 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/WiggleEffect.hx +++ b/Effects/BlendModeShaders/source/effects/WiggleEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.system.FlxAssets.FlxShader; @@ -18,38 +18,38 @@ class WiggleEffect public var waveSpeed(default, set):Float = 0; public var waveFrequency(default, set):Float = 0; public var waveAmplitude(default, set):Float = 0; - + public function new():Void { shader.uTime.value = [0]; } - + public function update(elapsed:Float):Void { shader.uTime.value[0] += elapsed; } - + function set_effectType(v:WiggleEffectType):WiggleEffectType { effectType = v; shader.effectType.value = [WiggleEffectType.getConstructors().indexOf(Std.string(v))]; return v; } - + function set_waveSpeed(v:Float):Float { waveSpeed = v; shader.uSpeed.value = [waveSpeed]; return v; } - + function set_waveFrequency(v:Float):Float { waveFrequency = v; shader.uFrequency.value = [waveFrequency]; return v; } - + function set_waveAmplitude(v:Float):Float { waveAmplitude = v; diff --git a/Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx deleted file mode 100644 index fa152e535..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx +++ /dev/null @@ -1,40 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class ColorBurnShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - float applyColorBurnToChannel(float base, float blend) - { - return ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0)); - } - - vec4 blendColorBurn(vec4 base, vec4 blend) - { - return vec4( - applyColorBurnToChannel(base.r, blend.r), - applyColorBurnToChannel(base.g, blend.g), - applyColorBurnToChannel(base.b, blend.b), - applyColorBurnToChannel(base.a, blend.a) - ); - } - - vec4 blendColorBurn(vec4 base, vec4 blend, float opacity) - { - return (blendColorBurn(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendColorBurn(base, uBlendColor, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx deleted file mode 100644 index 19dd72725..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx +++ /dev/null @@ -1,59 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class HardMixShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - float blendColorDodge(float base, float blend) { - return (blend == 1.0) - ? blend - : min(base / (1.0 - blend), 1.0); - } - - float blendColorBurn(float base, float blend) { - return (blend == 0.0) - ? blend - : max((1.0 - ((1.0 - base) / blend)), 0.0); - } - - float blendVividLight(float base, float blend) { - return (blend < 0.5) - ? blendColorBurn(base, (2.0 * blend)) - : blendColorDodge(base, (2.0 * (blend - 0.5))); - } - - float blendHardMix(float base, float blend) { - return (blendVividLight(base, blend) < 0.5) - ? 0.0 - : 1.0; - } - - vec4 blendHardMix(vec4 base, vec4 blend) { - return vec4( - blendHardMix(base.r, blend.r), - blendHardMix(base.g, blend.g), - blendHardMix(base.b, blend.b), - blendHardMix(base.a, blend.a) - ); - } - - vec4 blendHardMix(vec4 base, vec4 blend, float opacity) { - return (blendHardMix(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 blend = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - vec4 res = blendHardMix(uBlendColor, blend); - - gl_FragColor = blendHardMix(blend, res, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx deleted file mode 100644 index 3285fd786..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx +++ /dev/null @@ -1,30 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class LightenShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - vec4 blendLighten(vec4 base, vec4 blend) - { - return max(blend, base); - } - - vec4 blendLighten(vec4 base, vec4 blend, float opacity) - { - return (blendLighten(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendLighten(base, uBlendColor, uBlendColor.a); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx deleted file mode 100644 index f84cb6951..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx +++ /dev/null @@ -1,38 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class LinearDodgeShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - // Note : Same implementation as BlendAddf - float blendLinearDodge(float base, float blend) { - return min(base + blend, 1.0); - } - - vec4 blendLinearDodge(vec4 base, vec4 blend) { - return vec4( - blendLinearDodge(base.r, blend.r), - blendLinearDodge(base.g, blend.g), - blendLinearDodge(base.b, blend.b), - blendLinearDodge(base.a, blend.a) - ); - } - - vec4 blendLinearDodge(vec4 base, vec4 blend, float opacity) { - return (blendLinearDodge(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendLinearDodge(base, uBlendColor, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx deleted file mode 100644 index f35655e6d..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx +++ /dev/null @@ -1,30 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class MultiplyShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - vec4 blendMultiply(vec4 base, vec4 blend) - { - return base * blend; - } - - vec4 blendMultiply(vec4 base, vec4 blend, float opacity) - { - return (blendMultiply(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendMultiply(base, uBlendColor, uBlendColor.a); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx deleted file mode 100644 index f98665eb3..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx +++ /dev/null @@ -1,50 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class VividLightShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - float colorDodge(float base, float blend) - { - return (blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0); - } - - float colorBurn(float base, float blend) - { - return (blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0); - } - - float vividLight( float base, float blend ) - { - return ((blend < 0.5) ? colorBurn(base, (2.0 * blend)) : colorDodge(base, (2.0 * (blend - 0.5)))); - } - - vec4 vividLight(vec4 base, vec4 blend) - { - return vec4( - vividLight(base.r, blend.r), - vividLight(base.g, blend.g), - vividLight(base.b, blend.b), - vividLight(base.a, blend.a) - ); - } - - vec4 vividLight(vec4 base, vec4 blend, float opacity) - { - return (vividLight(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = vividLight(base, uBlendColor, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx deleted file mode 100644 index 32fcf5b2b..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx +++ /dev/null @@ -1,32 +0,0 @@ -package openfl3.effects; - -import flixel.util.FlxColor; - -typedef BlendModeShader = -{ - var uBlendColor(get, set):Array; -} - -class BlendModeEffect -{ - public var shader(default, null):BlendModeShader; - - @:isVar - public var color(default, set):FlxColor; - - public function new(shader:BlendModeShader, color:FlxColor):Void - { - this.shader = shader; - this.color = color; - } - - function set_color(color:FlxColor):FlxColor - { - shader.uBlendColor[0] = color.redFloat; - shader.uBlendColor[1] = color.greenFloat; - shader.uBlendColor[2] = color.blueFloat; - shader.uBlendColor[3] = color.alphaFloat; - - return this.color = color; - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx deleted file mode 100644 index f70557aa7..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx +++ /dev/null @@ -1,116 +0,0 @@ -package openfl3.effects; - -import flixel.util.FlxColor; -import openfl.display.Shader; - -class ColorSwapEffect -{ - /** - * The instance of the actual shader class - */ - public var shader(default, null):ColorSwapShader; - - /** - * The color to replace with another - */ - public var colorToReplace(default, set):FlxColor; - - /** - * The desired new color - */ - public var newColor(default, set):FlxColor; - - /** - * Activates/Deactivates the shader - */ - public var isShaderActive(default, set):Bool; - - public function new():Void - { - shader = new ColorSwapShader(); - shader.shaderIsActive = true; - } - - function set_isShaderActive(value:Bool):Bool - { - isShaderActive = value; - shader.shaderIsActive = value; - return value; - } - - function set_colorToReplace(color:FlxColor):FlxColor - { - colorToReplace = color; - - shader.colorOld[0] = color.red; - shader.colorOld[1] = color.green; - shader.colorOld[2] = color.blue; - - return color; - } - - function set_newColor(color:FlxColor):FlxColor - { - newColor = color; - - shader.colorNew[0] = color.red; - shader.colorNew[1] = color.green; - shader.colorNew[2] = color.blue; - - return color; - } -} - -class ColorSwapShader extends Shader -{ - @fragment var code = ' - uniform vec3 colorOld; - uniform vec3 colorNew; - uniform bool shaderIsActive; - - /** - * Helper method that normalizes an RGB value (in the 0-255 range) to a value between 0-1. - */ - vec3 normalizeColor(vec3 color) - { - return vec3( - color[0] / 255.0, - color[1] / 255.0, - color[2] / 255.0 - ); - } - - void main() - { - vec4 pixel = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - - if (!shaderIsActive) - { - gl_FragColor = pixel; - return; - } - - /** - * Used to create some leeway when comparing the colors. - * Smaller values = smaller leeway. - */ - vec3 eps = vec3(0.009, 0.009, 0.009); - - vec3 colorOldNormalized = normalizeColor(colorOld); - vec3 colorNewNormalized = normalizeColor(colorNew); - - if (all(greaterThanEqual(pixel, vec4(colorOldNormalized - eps, 1.0)) ) && - all(lessThanEqual(pixel, vec4(colorOldNormalized + eps, 1.0)) ) - ) - { - pixel = vec4(colorNewNormalized, 1.0); - } - - gl_FragColor = pixel; - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx deleted file mode 100644 index 324abe578..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx +++ /dev/null @@ -1,154 +0,0 @@ -package openfl3.effects; - -import flixel.FlxG; -import openfl.display.Shader; - -class ShutterEffect -{ - public static inline var SHUTTER_TARGET_FLXSPRITE:Int = 0; - public static inline var SHUTTER_TARGET_FLXCAMERA:Int = 1; - - public var shutterTargetMode(default, set):Int = 0; - - /** - * The instance of the actual shader class - */ - public var shader(default, null):ShutterShader; - - /** - * Size of the circle or "shutter" - */ - public var radius(default, set):Float; - - /** - * Center point of the "shutter" - */ - public var shutterCenterX(default, set):Float; - - public var shutterCenterY(default, set):Float; - - public var isActive(default, set):Bool; - - public function new():Void - { - shader = new ShutterShader(); - setResolution(); - isActive = true; - shutterCenterX = FlxG.width * .5; - shutterCenterY = FlxG.height * .5; - shutterTargetMode = SHUTTER_TARGET_FLXSPRITE; - radius = 0; - } - - function setResolution():Void - { - shader.uResolution[0] = FlxG.width; - shader.uResolution[1] = FlxG.height; - } - - function set_shutterTargetMode(v:Int):Int - { - shutterTargetMode = v; - shader.shutterTargetMode = shutterTargetMode; - return v; - } - - function set_isActive(v:Bool):Bool - { - isActive = v; - shader.shaderIsActive = isActive; - return v; - } - - function set_radius(v:Float):Float - { - radius = (v <= 0.0 ? 0.0 : v); - shader.uCircleRadius = radius; - return v; - } - - function set_shutterCenterX(v:Float):Float - { - shutterCenterX = v; - shader.centerPtX = v; - return v; - } - - function set_shutterCenterY(v:Float):Float - { - shutterCenterY = v; - shader.centerPtY = v; - return v; - } -} - -class ShutterShader extends Shader -{ - @fragment var code = ' - #ifdef GL_ES - precision mediump float; - #endif - - const int SHUTTER_TARGET_FLXSPRITE = 0; - const int SHUTTER_TARGET_FLXCAMERA = 1; - const float scale = 1.0; - - uniform vec2 uResolution; - uniform float centerPtX; - uniform float centerPtY; - uniform float uCircleRadius; - uniform int shutterTargetMode; - uniform bool shaderIsActive; - - vec2 getCoordinates() - { - return vec2( - (${Shader.vTexCoord}.x * uResolution.x) / scale, - (${Shader.vTexCoord}.y * uResolution.y) / scale - ); - } - - float getDist(vec2 pt1, vec2 pt2) - { - float dx = pt1.x - pt2.x; - float dy = pt1.y - pt2.y; - - return sqrt( - (dx*dx) + (dy*dy) - ); - } - - void main() - { - if (!shaderIsActive) - { - gl_FragColor = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - return; - } - - vec2 centerPt = vec2(centerPtX, centerPtY); - - if (uCircleRadius <= 0.0 || getDist(getCoordinates(), centerPt) > uCircleRadius) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - else - { - /* If this shader is used on a FlxCamera, uncomment the line below to - draw the underlying pixels inside the shutter (as they would look normally). - - If using this shader on a FlxSprite, keep the line below commented out, to - draw transparency inside the shutter */ - - if (shutterTargetMode == SHUTTER_TARGET_FLXCAMERA) - { - gl_FragColor = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - } - } - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx deleted file mode 100644 index 3f2809aaa..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx +++ /dev/null @@ -1,129 +0,0 @@ -package openfl3.effects; - -import openfl.display.Shader; - -enum WiggleEffectType -{ - DREAMY; - WAVY; - HEAT_WAVE_HORIZONTAL; - HEAT_WAVE_VERTICAL; - FLAG; -} - -class WiggleEffect -{ - public var effectType(default, set):WiggleEffectType = DREAMY; - public var shader(default, null):WiggleShader = new WiggleShader(); - public var waveSpeed(default, set):Float = 0; - public var waveFrequency(default, set):Float = 0; - public var waveAmplitude(default, set):Float = 0; - - public function new():Void {} - - public function update(elapsed:Float):Void - { - shader.uTime += elapsed; - } - - function set_effectType(v:WiggleEffectType):WiggleEffectType - { - effectType = v; - shader.effectType = WiggleEffectType.getConstructors().indexOf(Std.string(v)); - return v; - } - - function set_waveSpeed(v:Float):Float - { - waveSpeed = v; - shader.uSpeed = waveSpeed; - return v; - } - - function set_waveFrequency(v:Float):Float - { - waveFrequency = v; - shader.uFrequency = waveFrequency; - return v; - } - - function set_waveAmplitude(v:Float):Float - { - waveAmplitude = v; - shader.uWaveAmplitude = waveAmplitude; - return v; - } -} - -class WiggleShader extends Shader -{ - @fragment var code = ' - //uniform float tx, ty; // x,y waves phase - uniform float uTime; - - const int EFFECT_TYPE_DREAMY = 0; - const int EFFECT_TYPE_WAVY = 1; - const int EFFECT_TYPE_HEAT_WAVE_HORIZONTAL = 2; - const int EFFECT_TYPE_HEAT_WAVE_VERTICAL = 3; - const int EFFECT_TYPE_FLAG = 4; - - uniform int effectType; - - /** - * How fast the waves move over time - */ - uniform float uSpeed; - - /** - * Number of waves over time - */ - uniform float uFrequency; - - /** - * How much the pixels are going to stretch over the waves - */ - uniform float uWaveAmplitude; - - vec2 sineWave(vec2 pt) - { - float x = 0.0; - float y = 0.0; - - if (effectType == EFFECT_TYPE_DREAMY) - { - float offsetX = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude; - pt.x += offsetX; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving - } - else if (effectType == EFFECT_TYPE_WAVY) - { - float offsetY = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude; - pt.y += offsetY; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving - } - else if (effectType == EFFECT_TYPE_HEAT_WAVE_HORIZONTAL) - { - x = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude; - } - else if (effectType == EFFECT_TYPE_HEAT_WAVE_VERTICAL) - { - y = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude; - } - else if (effectType == EFFECT_TYPE_FLAG) - { - y = sin(pt.y * uFrequency + 10.0 * pt.x + uTime * uSpeed) * uWaveAmplitude; - x = sin(pt.x * uFrequency + 5.0 * pt.y + uTime * uSpeed) * uWaveAmplitude; - } - - return vec2(pt.x + x, pt.y + y); - } - - void main() - { - vec2 uv = sineWave(${Shader.vTexCoord}); - gl_FragColor = texture2D(${Shader.uSampler}, uv); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/DynamicShadows/source/PlayStateShader.hx b/Effects/DynamicShadows/source/PlayStateShader.hx index ea05e9bc0..245c0f42c 100644 --- a/Effects/DynamicShadows/source/PlayStateShader.hx +++ b/Effects/DynamicShadows/source/PlayStateShader.hx @@ -1,6 +1,7 @@ import openfl.display.BitmapData; import flixel.FlxCamera; import flixel.FlxG; + class PlayStateShader extends PlayState { var shaderCam:FlxCamera; @@ -34,7 +35,7 @@ class PlayStateShader extends PlayState // add the bg camera as an image to the shader so we can add color effects to it bgCam.buffer = new BitmapData(bgCam.width, bgCam.height); shader.bgImage.input = bgCam.buffer; - shaderCam.setFilters([new openfl.filters.ShaderFilter(shader)]); + shaderCam.filters = [new openfl.filters.ShaderFilter(shader)]; // draws anything above the shadows, in this case infoText uiCam = new FlxCamera(0, 0, FlxG.width, FlxG.height); @@ -47,7 +48,8 @@ class PlayStateShader extends PlayState { super.update(elapsed); - inline function random(mean:Float) return FlxG.random.floatNormal(mean, mean / 8); + inline function random(mean:Float) + return FlxG.random.floatNormal(mean, mean / 8); shader.setOrigin((gem.x + random(gem.origin.x)) / FlxG.width, (gem.y + random(gem.origin.y)) / FlxG.height); } @@ -72,4 +74,4 @@ class PlayStateShader extends PlayState } return buffer; } -} \ No newline at end of file +} diff --git a/Effects/Filters/source/PlayState.hx b/Effects/Filters/source/PlayState.hx index 420083f2d..931a8f3e7 100644 --- a/Effects/Filters/source/PlayState.hx +++ b/Effects/Filters/source/PlayState.hx @@ -1,22 +1,18 @@ package; -import flixel.addons.display.FlxBackdrop; -import flixel.addons.ui.FlxUIAssets; -import flixel.addons.ui.FlxUICheckBox; import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxState; +import flixel.addons.display.FlxBackdrop; +import flixel.addons.ui.FlxUIAssets; +import flixel.addons.ui.FlxUICheckBox; import openfl.filters.BitmapFilter; import openfl.filters.BlurFilter; import openfl.filters.ColorMatrixFilter; #if shaders_supported -#if (openfl >= "8.0.0") -import openfl8.*; -#else -import openfl3.*; -#end -import openfl.filters.ShaderFilter; +import filters.*; import openfl.Lib; +import openfl.filters.ShaderFilter; #end class PlayState extends FlxState @@ -24,7 +20,7 @@ class PlayState extends FlxState var filters:Array = []; var uiCamera:flixel.FlxCamera; var filterMap:MapVoid}>; - + override public function create():Void { filterMap = [ @@ -60,7 +56,7 @@ class PlayState extends FlxState 0.5, 0.5, 0.5, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Invert" => { @@ -70,7 +66,7 @@ class PlayState extends FlxState 0, 0, -1, 0, 255, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Deuteranopia" => { @@ -80,7 +76,7 @@ class PlayState extends FlxState -.02, 0.03, 1, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Protanopia" => { @@ -90,7 +86,7 @@ class PlayState extends FlxState 0.01, -.01, 1, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Tritanopia" => { @@ -100,51 +96,51 @@ class PlayState extends FlxState 0.06, 0.88, 0.18, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} } ]; - + uiCamera = new FlxCamera(0, 0, 130, 300); FlxG.cameras.add(uiCamera); - + var backdrop = new FlxBackdrop("assets/logo.png"); backdrop.cameras = [FlxG.camera]; backdrop.velocity.set(150, 150); add(backdrop); - - FlxG.camera.setFilters(filters); - FlxG.game.setFilters(filters); - + + FlxG.camera.filters = filters; + FlxG.game.filters = filters; + FlxG.game.filtersEnabled = false; - + var x = 10; var y = 10; - + for (key in filterMap.keys()) { createCheckbox(x, y, key, filterMap.get(key).filter); y += 25; } - + y += 10; var checkbox = new FlxUICheckBox(x, y, FlxUIAssets.IMG_CHECK_BOX, FlxUIAssets.IMG_CHECK_MARK, "Apply to full game"); checkbox.cameras = [uiCamera]; add(checkbox); - + checkbox.callback = function() { FlxG.camera.filtersEnabled = !checkbox.checked; FlxG.game.filtersEnabled = checkbox.checked; } } - + function createCheckbox(x:Float, y:Float, name:String, filter:BitmapFilter) { var checkbox = new FlxUICheckBox(x, y, FlxUIAssets.IMG_CHECK_BOX, FlxUIAssets.IMG_CHECK_MARK, name); checkbox.cameras = [uiCamera]; add(checkbox); - + checkbox.callback = function() { if (checkbox.checked) @@ -153,11 +149,11 @@ class PlayState extends FlxState filters.remove(filter); } } - + override public function update(elapsed:Float):Void { super.update(elapsed); - + for (filter in filterMap) { if (filter.onUpdate != null) diff --git a/Effects/Filters/source/openfl8/Grain.hx b/Effects/Filters/source/filters/Grain.hx similarity index 99% rename from Effects/Filters/source/openfl8/Grain.hx rename to Effects/Filters/source/filters/Grain.hx index 96a87defc..2aabbca9f 100644 --- a/Effects/Filters/source/openfl8/Grain.hx +++ b/Effects/Filters/source/filters/Grain.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl8/Hq2x.hx b/Effects/Filters/source/filters/Hq2x.hx similarity index 98% rename from Effects/Filters/source/openfl8/Hq2x.hx rename to Effects/Filters/source/filters/Hq2x.hx index 4a762472e..6c576ff50 100644 --- a/Effects/Filters/source/openfl8/Hq2x.hx +++ b/Effects/Filters/source/filters/Hq2x.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl8/Scanline.hx b/Effects/Filters/source/filters/Scanline.hx similarity index 96% rename from Effects/Filters/source/openfl8/Scanline.hx rename to Effects/Filters/source/filters/Scanline.hx index 535dfae7a..00f4463f5 100644 --- a/Effects/Filters/source/openfl8/Scanline.hx +++ b/Effects/Filters/source/filters/Scanline.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl8/Tiltshift.hx b/Effects/Filters/source/filters/Tiltshift.hx similarity index 99% rename from Effects/Filters/source/openfl8/Tiltshift.hx rename to Effects/Filters/source/filters/Tiltshift.hx index 85aa02455..0613d9fab 100644 --- a/Effects/Filters/source/openfl8/Tiltshift.hx +++ b/Effects/Filters/source/filters/Tiltshift.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl3/Grain.hx b/Effects/Filters/source/openfl3/Grain.hx deleted file mode 100644 index 974c63336..000000000 --- a/Effects/Filters/source/openfl3/Grain.hx +++ /dev/null @@ -1,149 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Grain extends Shader -{ - @fragment var code = ' - /* - Film Grain post-process shader v1.1 - Martins Upitis (martinsh) devlog-martinsh.blogspot.com - 2013 - - -------------------------- - This work is licensed under a Creative Commons Attribution 3.0 Unported License. - So you are free to share, modify and adapt it for your needs, and even use it for commercial use. - I would also love to hear about a project you are using it. - - Have fun, - Martins - -------------------------- - - Perlin noise shader by toneburst: - http://machinesdontcare.wordpress.com/2009/06/25/3d-perlin-noise-sphere-vertex-shader-sourcecode/ - */ - uniform float uTime; - - const float permTexUnit = 1.0/256.0; // Perm texture texel-size - const float permTexUnitHalf = 0.5/256.0; // Half perm texture texel-size - - float width = ${Shader.uTextureSize}.x; - float height = ${Shader.uTextureSize}.y; - - const float grainamount = 0.05; //grain amount - bool colored = false; //colored noise? - float coloramount = 0.6; - float grainsize = 1.6; //grain particle size (1.5 - 2.5) - float lumamount = 1.0; // - - //a random texture generator, but you can also use a pre-computed perturbation texture - vec4 rnm(in vec2 tc) - { - float noise = sin(dot(tc + vec2(uTime,uTime),vec2(12.9898,78.233))) * 43758.5453; - - float noiseR = fract(noise)*2.0-1.0; - float noiseG = fract(noise*1.2154)*2.0-1.0; - float noiseB = fract(noise*1.3453)*2.0-1.0; - float noiseA = fract(noise*1.3647)*2.0-1.0; - - return vec4(noiseR,noiseG,noiseB,noiseA); - } - - float fade(in float t) { - return t*t*t*(t*(t*6.0-15.0)+10.0); - } - - float pnoise3D(in vec3 p) - { - vec3 pi = permTexUnit*floor(p)+permTexUnitHalf; // Integer part, scaled so +1 moves permTexUnit texel - // and offset 1/2 texel to sample texel centers - vec3 pf = fract(p); // Fractional part for interpolation - - // Noise contributions from (x=0, y=0), z=0 and z=1 - float perm00 = rnm(pi.xy).a ; - vec3 grad000 = rnm(vec2(perm00, pi.z)).rgb * 4.0 - 1.0; - float n000 = dot(grad000, pf); - vec3 grad001 = rnm(vec2(perm00, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n001 = dot(grad001, pf - vec3(0.0, 0.0, 1.0)); - - // Noise contributions from (x=0, y=1), z=0 and z=1 - float perm01 = rnm(pi.xy + vec2(0.0, permTexUnit)).a ; - vec3 grad010 = rnm(vec2(perm01, pi.z)).rgb * 4.0 - 1.0; - float n010 = dot(grad010, pf - vec3(0.0, 1.0, 0.0)); - vec3 grad011 = rnm(vec2(perm01, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n011 = dot(grad011, pf - vec3(0.0, 1.0, 1.0)); - - // Noise contributions from (x=1, y=0), z=0 and z=1 - float perm10 = rnm(pi.xy + vec2(permTexUnit, 0.0)).a ; - vec3 grad100 = rnm(vec2(perm10, pi.z)).rgb * 4.0 - 1.0; - float n100 = dot(grad100, pf - vec3(1.0, 0.0, 0.0)); - vec3 grad101 = rnm(vec2(perm10, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n101 = dot(grad101, pf - vec3(1.0, 0.0, 1.0)); - - // Noise contributions from (x=1, y=1), z=0 and z=1 - float perm11 = rnm(pi.xy + vec2(permTexUnit, permTexUnit)).a ; - vec3 grad110 = rnm(vec2(perm11, pi.z)).rgb * 4.0 - 1.0; - float n110 = dot(grad110, pf - vec3(1.0, 1.0, 0.0)); - vec3 grad111 = rnm(vec2(perm11, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n111 = dot(grad111, pf - vec3(1.0, 1.0, 1.0)); - - // Blend contributions along x - vec4 n_x = mix(vec4(n000, n001, n010, n011), vec4(n100, n101, n110, n111), fade(pf.x)); - - // Blend contributions along y - vec2 n_xy = mix(n_x.xy, n_x.zw, fade(pf.y)); - - // Blend contributions along z - float n_xyz = mix(n_xy.x, n_xy.y, fade(pf.z)); - - // We are done, return the final noise value. - return n_xyz; - } - - //2d coordinate orientation thing - vec2 coordRot(in vec2 tc, in float angle) - { - float aspect = width/height; - float rotX = ((tc.x*2.0-1.0)*aspect*cos(angle)) - ((tc.y*2.0-1.0)*sin(angle)); - float rotY = ((tc.y*2.0-1.0)*cos(angle)) + ((tc.x*2.0-1.0)*aspect*sin(angle)); - rotX = ((rotX/aspect)*0.5+0.5); - rotY = rotY*0.5+0.5; - return vec2(rotX,rotY); - } - - void main() - { - vec2 texCoord = ${Shader.vTexCoord}.st; - - vec3 rotOffset = vec3(1.425,3.892,5.835); //rotation offset values - vec2 rotCoordsR = coordRot(texCoord, uTime + rotOffset.x); - vec3 noise = vec3(pnoise3D(vec3(rotCoordsR*vec2(width/grainsize,height/grainsize),0.0))); - - if (colored) - { - vec2 rotCoordsG = coordRot(texCoord, uTime + rotOffset.y); - vec2 rotCoordsB = coordRot(texCoord, uTime + rotOffset.z); - noise.g = mix(noise.r,pnoise3D(vec3(rotCoordsG*vec2(width/grainsize,height/grainsize),1.0)),coloramount); - noise.b = mix(noise.r,pnoise3D(vec3(rotCoordsB*vec2(width/grainsize,height/grainsize),2.0)),coloramount); - } - - vec3 col = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}).rgb; - - //noisiness response curve based on scene luminance - vec3 lumcoeff = vec3(0.299,0.587,0.114); - float luminance = mix(0.0,dot(col, lumcoeff),lumamount); - float lum = smoothstep(0.2,0.0,luminance); - lum += luminance; - - - noise = mix(noise,vec3(0.0),pow(lum,4.0)); - col = col+noise*grainamount; - - gl_FragColor = vec4(col,1.0); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/Filters/source/openfl3/Hq2x.hx b/Effects/Filters/source/openfl3/Hq2x.hx deleted file mode 100644 index 72ff8558c..000000000 --- a/Effects/Filters/source/openfl3/Hq2x.hx +++ /dev/null @@ -1,33 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Hq2x extends Shader -{ - @fragment var code = ' - void main() - { - float x = 1.0 / ${Shader.uTextureSize}.x; - float y = 1.0 / ${Shader.uTextureSize}.y; - - vec4 color1 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(-x, -y)); - vec4 color2 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(0.0, -y)); - vec4 color3 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(x, -y)); - - vec4 color4 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(-x, 0.0)); - vec4 color5 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(0.0, 0.0)); - vec4 color6 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(x, 0.0)); - - vec4 color7 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(-x, y)); - vec4 color8 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(0.0, y)); - vec4 color9 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(x, y)); - vec4 avg = color1 + color2 + color3 + color4 + color5 + color6 + color7 + color8 + color9; - - gl_FragColor = avg / 9.0; - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/Filters/source/openfl3/Scanline.hx b/Effects/Filters/source/openfl3/Scanline.hx deleted file mode 100644 index 6e1ab853b..000000000 --- a/Effects/Filters/source/openfl3/Scanline.hx +++ /dev/null @@ -1,22 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Scanline extends Shader -{ - @fragment var fragment = ' - const float scale = 1.0; - - void main() - { - if (mod(floor(${Shader.vTexCoord}.y * ${Shader.uTextureSize}.y / scale), 2.0) == 0.0) - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - else - gl_FragColor = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/Filters/source/openfl3/Tiltshift.hx b/Effects/Filters/source/openfl3/Tiltshift.hx deleted file mode 100644 index 9bffd2cdd..000000000 --- a/Effects/Filters/source/openfl3/Tiltshift.hx +++ /dev/null @@ -1,89 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Tiltshift extends Shader -{ - @fragment var code = ' - // Modified version of a tilt shift shader from Martin Jonasson (http://grapefrukt.com/) - // Read http://notes.underscorediscovery.com/ for context on shaders and this file - // License : MIT - - /* - Take note that blurring in a single pass (the two for loops below) is more expensive than separating - the x and the y blur into different passes. This was used where bleeding edge performance - was not crucial and is to illustrate a point. - - The reason two passes is cheaper? - texture2D is a fairly high cost call, sampling a texture. - - So, in a single pass, like below, there are 3 steps, per x and y. - - That means a total of 9 "taps", it touches the texture to sample 9 times. - - Now imagine we apply this to some geometry, that is equal to 16 pixels on screen (tiny) - (16 * 16) * 9 = 2304 samples taken, for width * height number of pixels, * 9 taps - Now, if you split them up, it becomes 3 for x, and 3 for y, a total of 6 taps - (16 * 16) * 6 = 1536 samples - - That\'s on a *tiny* sprite, let\'s scale that up to 128x128 sprite... - (128 * 128) * 9 = 147,456 - (128 * 128) * 6 = 98,304 - - That\'s 33.33..% cheaper for splitting them up. - That\'s with 3 steps, with higher steps (more taps per pass...) - - A really smooth, 6 steps, 6*6 = 36 taps for one pass, 12 taps for two pass - You will notice, the curve is not linear, at 12 steps it\'s 144 vs 24 taps - It becomes orders of magnitude slower to do single pass! - Therefore, you split them up into two passes, one for x, one for y. - */ - - // I am hardcoding the constants like a jerk - - const float bluramount = 1.0; - const float center = 1.0; - const float stepSize = 0.004; - const float steps = 3.0; - - const float minOffs = (float(steps-1.0)) / -2.0; - const float maxOffs = (float(steps-1.0)) / +2.0; - - void main() { - float amount; - vec4 blurred; - - // Work out how much to blur based on the mid point - amount = pow((${Shader.vTexCoord}.y * center) * 2.0 - 1.0, 2.0) * bluramount; - - // This is the accumulation of color from the surrounding pixels in the texture - blurred = vec4(0.0, 0.0, 0.0, 1.0); - - // From minimum offset to maximum offset - for (float offsX = minOffs; offsX <= maxOffs; ++offsX) { - for (float offsY = minOffs; offsY <= maxOffs; ++offsY) { - - // copy the coord so we can mess with it - vec2 temp_tcoord = ${Shader.vTexCoord}.xy; - - //work out which uv we want to sample now - temp_tcoord.x += offsX * amount * stepSize; - temp_tcoord.y += offsY * amount * stepSize; - - // accumulate the sample - blurred += texture2D(${Shader.uSampler}, temp_tcoord); - } - } - - // because we are doing an average, we divide by the amount (x AND y, hence steps * steps) - blurred /= float(steps * steps); - - // return the final blurred color - gl_FragColor = blurred; - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/FlxTrailArea/source/BlurState.hx b/Effects/FlxTrailArea/source/BlurState.hx index 35cc4bada..15fe58b72 100644 --- a/Effects/FlxTrailArea/source/BlurState.hx +++ b/Effects/FlxTrailArea/source/BlurState.hx @@ -66,7 +66,7 @@ class BlurState extends FlxState // Toggle states if (FlxG.keys.justReleased.SPACE) { - FlxG.switchState(new ParticleState()); + FlxG.switchState(ParticleState.new); } } } diff --git a/Effects/FlxTrailArea/source/ParticleState.hx b/Effects/FlxTrailArea/source/ParticleState.hx index 0249258eb..9b586e74e 100644 --- a/Effects/FlxTrailArea/source/ParticleState.hx +++ b/Effects/FlxTrailArea/source/ParticleState.hx @@ -77,7 +77,7 @@ class ParticleState extends FlxState // Toggle states if (FlxG.keys.justReleased.SPACE) - FlxG.switchState(new BlurState()); + FlxG.switchState(BlurState.new); } /** diff --git a/Effects/Transitions/source/MenuState.hx b/Effects/Transitions/source/MenuState.hx index 904718cf5..da43258ce 100644 --- a/Effects/Transitions/source/MenuState.hx +++ b/Effects/Transitions/source/MenuState.hx @@ -19,43 +19,48 @@ import flixel.util.FlxColor; class MenuState extends FlxUIState { static var initialized:Bool = false; - + + public function new() + { + super(); + } + override public function create():Void { _xml_id = "ui"; super.create(); init(); } - + function init():Void { if (!initialized) { initialized = true; - + // If this is the first time we've run the program, we initialize the TransitionData - + // When we set the default static transIn/transOut values, on construction all // FlxTransitionableStates will use those values if their own transIn/transOut states are null FlxTransitionableState.defaultTransIn = new TransitionData(); FlxTransitionableState.defaultTransOut = new TransitionData(); - + var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond); diamond.persist = true; diamond.destroyOnNoUse = false; - + FlxTransitionableState.defaultTransIn.tileData = {asset: diamond, width: 32, height: 32}; FlxTransitionableState.defaultTransOut.tileData = {asset: diamond, width: 32, height: 32}; - + // Of course, this state has already been constructed, so we need to set a transOut value for it right now: transOut = FlxTransitionableState.defaultTransOut; } - + // Now we just have the UI synchronize with the starting values: matchTransitionData(); matchUI(false); } - + function matchUI(matchData:Bool = true):Void { var in_duration:FlxUINumericStepper = cast _ui.getAsset("in_duration"); @@ -63,34 +68,34 @@ class MenuState extends FlxUIState var in_tile:FlxUIRadioGroup = cast _ui.getAsset("in_tile"); var in_color:FlxUIRadioGroup = cast _ui.getAsset("in_color"); var in_dir:FlxUIRadioGroup = cast _ui.getAsset("in_dir"); - + var out_duration:FlxUINumericStepper = cast _ui.getAsset("out_duration"); var out_type:FlxUIRadioGroup = cast _ui.getAsset("out_type"); var out_tile:FlxUIRadioGroup = cast _ui.getAsset("out_tile"); var out_color:FlxUIRadioGroup = cast _ui.getAsset("out_color"); var out_dir:FlxUIRadioGroup = cast _ui.getAsset("out_dir"); - + FlxTransitionableState.defaultTransIn.color = FlxColor.fromString(in_color.selectedId); FlxTransitionableState.defaultTransIn.type = cast in_type.selectedId; setDirectionFromStr(in_dir.selectedId, FlxTransitionableState.defaultTransIn.direction); FlxTransitionableState.defaultTransIn.duration = in_duration.value; FlxTransitionableState.defaultTransIn.tileData.asset = getDefaultAsset(in_tile.selectedId); - + FlxTransitionableState.defaultTransOut.color = FlxColor.fromString(out_color.selectedId); FlxTransitionableState.defaultTransOut.type = cast out_type.selectedId; setDirectionFromStr(out_dir.selectedId, FlxTransitionableState.defaultTransOut.direction); FlxTransitionableState.defaultTransOut.duration = out_duration.value; FlxTransitionableState.defaultTransOut.tileData.asset = getDefaultAsset(out_tile.selectedId); - + transIn = FlxTransitionableState.defaultTransIn; transOut = FlxTransitionableState.defaultTransOut; - + if (matchData) { matchTransitionData(); } } - + function matchTransitionData():Void { var in_duration:FlxUINumericStepper = cast _ui.getAsset("in_duration"); @@ -99,14 +104,14 @@ class MenuState extends FlxUIState var in_tile_text:FlxUIText = cast _ui.getAsset("in_tile_text"); var in_color:FlxUIRadioGroup = cast _ui.getAsset("in_color"); var in_dir:FlxUIRadioGroup = cast _ui.getAsset("in_dir"); - + var out_duration:FlxUINumericStepper = cast _ui.getAsset("out_duration"); var out_type:FlxUIRadioGroup = cast _ui.getAsset("out_type"); var out_tile:FlxUIRadioGroup = cast _ui.getAsset("out_tile"); var out_tile_text:FlxUIText = cast _ui.getAsset("out_tile_text"); var out_color:FlxUIRadioGroup = cast _ui.getAsset("out_color"); var out_dir:FlxUIRadioGroup = cast _ui.getAsset("out_dir"); - + in_duration.value = FlxTransitionableState.defaultTransIn.duration; in_type.selectedId = cast FlxTransitionableState.defaultTransIn.type; if (FlxTransitionableState.defaultTransIn.type == TILES) @@ -129,7 +134,7 @@ class MenuState extends FlxUIState case _: "black"; } in_dir.selectedId = getDirection(cast FlxTransitionableState.defaultTransIn.direction.x, cast FlxTransitionableState.defaultTransIn.direction.y); - + out_duration.value = FlxTransitionableState.defaultTransOut.duration; out_type.selectedId = cast FlxTransitionableState.defaultTransOut.type; if (FlxTransitionableState.defaultTransOut.type == TILES) @@ -142,7 +147,7 @@ class MenuState extends FlxUIState { out_tile_text.visible = out_tile.visible = false; } - + out_color.selectedId = switch (FlxTransitionableState.defaultTransOut.color) { case FlxColor.RED: "red"; @@ -152,10 +157,10 @@ class MenuState extends FlxUIState case FlxColor.GREEN: "green"; case _: "black"; } - + out_dir.selectedId = getDirection(cast FlxTransitionableState.defaultTransOut.direction.x, cast FlxTransitionableState.defaultTransOut.direction.y); } - + function getDefaultAssetStr(c:FlxGraphic):String { return switch (c.assetsClass) @@ -165,7 +170,7 @@ class MenuState extends FlxUIState case GraphicTransTileDiamond, _: "diamond"; } } - + function getDefaultAsset(str):FlxGraphic { var graphicClass:Class = switch (str) @@ -174,13 +179,13 @@ class MenuState extends FlxUIState case "square": GraphicTransTileSquare; case "diamond", _: GraphicTransTileDiamond; } - + var graphic = FlxGraphic.fromClass(cast graphicClass); graphic.persist = true; graphic.destroyOnNoUse = false; return graphic; } - + function getDirection(ix:Int, iy:Int):String { if (ix < 0) @@ -210,12 +215,12 @@ class MenuState extends FlxUIState } return "center"; } - + function setDirectionFromStr(str:String, ?p:FlxPoint):FlxPoint { if (p == null) p = new FlxPoint(); - + switch (str) { case "n": @@ -239,12 +244,12 @@ class MenuState extends FlxUIState } return p; } - + function transition():Void { - FlxG.switchState(new MenuStateB()); + FlxG.switchState(MenuStateB.new); } - + override public function getEvent(id:String, sender:Dynamic, data:Dynamic, ?params:Array):Void { switch (id) diff --git a/Effects/Transitions/source/MenuStateB.hx b/Effects/Transitions/source/MenuStateB.hx index 57fab0af4..56bf761e1 100644 --- a/Effects/Transitions/source/MenuStateB.hx +++ b/Effects/Transitions/source/MenuStateB.hx @@ -17,9 +17,9 @@ class MenuStateB extends MenuState var welcome:FlxUIText = cast _ui.getAsset("welcome"); welcome.text = "STATE B"; } - + override function transition():Void { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } } diff --git a/Features/FlxNapeTilemap/source/Main.hx b/Features/FlxNapeTilemap/source/Main.hx index 755e813af..283f9709f 100644 --- a/Features/FlxNapeTilemap/source/Main.hx +++ b/Features/FlxNapeTilemap/source/Main.hx @@ -2,7 +2,6 @@ package; import flixel.FlxGame; import openfl.display.Sprite; -import states.PlayState; class Main extends Sprite { diff --git a/Features/FlxNapeTilemap/source/states/PlayState.hx b/Features/FlxNapeTilemap/source/PlayState.hx similarity index 97% rename from Features/FlxNapeTilemap/source/states/PlayState.hx rename to Features/FlxNapeTilemap/source/PlayState.hx index abfbcd444..7b01e2acb 100644 --- a/Features/FlxNapeTilemap/source/states/PlayState.hx +++ b/Features/FlxNapeTilemap/source/PlayState.hx @@ -1,5 +1,3 @@ -package states; - import flixel.addons.nape.*; import flixel.FlxG; import flixel.FlxState; @@ -91,7 +89,7 @@ class PlayState extends FlxState } } -@:enum abstract Level(String) to String +enum abstract Level(String) to String { var FIRST = "assets/testmap.csv"; var SECOND = "assets/testmap2.csv"; diff --git a/Features/Replay/source/PlayState.hx b/Features/Replay/source/PlayState.hx index 143ecc15d..ea5aee9ef 100644 --- a/Features/Replay/source/PlayState.hx +++ b/Features/Replay/source/PlayState.hx @@ -165,6 +165,6 @@ class PlayState extends FlxState */ var save:String = FlxG.vcr.stopRecording(false); - FlxG.vcr.loadReplay(save, new PlayState(), ["ANY", "MOUSE"], 0, startRecording); + FlxG.vcr.loadReplay(save, PlayState.new, ["ANY", "MOUSE"], 0, startRecording); } } diff --git a/Features/ScaleModes/source/PlayState.hx b/Features/ScaleModes/source/PlayState.hx index 7a0b9ed2e..dd4340118 100644 --- a/Features/ScaleModes/source/PlayState.hx +++ b/Features/ScaleModes/source/PlayState.hx @@ -72,8 +72,7 @@ class PlayState extends FlxState } } -@:enum -abstract ScaleMode(String) to String +enum abstract ScaleMode(String) to String { var RATIO_DEFAULT = "ratio"; var RATIO_FILL_SCREEN = "ratio (screenfill)"; diff --git a/Other/BSPMapGen/source/generate/GenerateState.hx b/Other/BSPMapGen/source/generate/GenerateState.hx index 379637477..e6d10ddfa 100644 --- a/Other/BSPMapGen/source/generate/GenerateState.hx +++ b/Other/BSPMapGen/source/generate/GenerateState.hx @@ -148,6 +148,6 @@ class GenerateState extends FlxState function play():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } diff --git a/Other/BSPMapGen/source/play/PlayState.hx b/Other/BSPMapGen/source/play/PlayState.hx index cea5a65b9..2fd072ce3 100644 --- a/Other/BSPMapGen/source/play/PlayState.hx +++ b/Other/BSPMapGen/source/play/PlayState.hx @@ -45,6 +45,6 @@ class PlayState extends FlxState function back():Void { - FlxG.switchState(new GenerateState()); + FlxG.switchState(GenerateState.new); } } diff --git a/Other/Calculator/source/State.hx b/Other/Calculator/source/State.hx index 5e8373a04..a0e35d75e 100644 --- a/Other/Calculator/source/State.hx +++ b/Other/Calculator/source/State.hx @@ -13,7 +13,6 @@ import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxRandom; import flixel.math.FlxRect; -import flixel.math.FlxVector; import flixel.math.FlxVelocity; import flixel.system.scaleModes.PixelPerfectScaleMode; import flixel.text.FlxText; diff --git a/Other/FlxCollisions/source/PlayState.hx b/Other/FlxCollisions/source/PlayState.hx index 759feb048..ae434b2b2 100644 --- a/Other/FlxCollisions/source/PlayState.hx +++ b/Other/FlxCollisions/source/PlayState.hx @@ -105,7 +105,7 @@ class PlayState extends FlxState if (FlxG.keys.justReleased.ENTER) { - FlxG.switchState(new PlayState2()); + FlxG.switchState(PlayState2.new); } super.update(elapsed); diff --git a/Other/FlxCollisions/source/PlayState2.hx b/Other/FlxCollisions/source/PlayState2.hx index 6c9626921..a9ed868f6 100644 --- a/Other/FlxCollisions/source/PlayState2.hx +++ b/Other/FlxCollisions/source/PlayState2.hx @@ -96,7 +96,7 @@ class PlayState2 extends FlxState if (FlxG.keys.justReleased.ENTER) { - FlxG.switchState(new PlayState3()); + FlxG.switchState(PlayState3.new); } } } diff --git a/Other/FlxCollisions/source/PlayState3.hx b/Other/FlxCollisions/source/PlayState3.hx index ab14418df..d09bc56c7 100644 --- a/Other/FlxCollisions/source/PlayState3.hx +++ b/Other/FlxCollisions/source/PlayState3.hx @@ -75,7 +75,7 @@ class PlayState3 extends FlxState if (FlxG.keys.justReleased.ENTER) { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } } diff --git a/Other/FrameCollections/source/PlayState.hx b/Other/FrameCollections/source/PlayState.hx index 2cb2388dc..839c67161 100644 --- a/Other/FrameCollections/source/PlayState.hx +++ b/Other/FrameCollections/source/PlayState.hx @@ -86,7 +86,7 @@ class PlayState extends FlxState bitmapText.autoSize = true; bitmapText.multiLine = true; - bitmapText.wrapByWord = true; + bitmapText.wrap = WORD(NEVER); bitmapText.text = "Math \n for game developers"; bitmapText.y = 40; bitmapText.alignment = CENTER; diff --git a/Performance/PixelPerfectCollision/source/PlayState.hx b/Performance/PixelPerfectCollision/source/PlayState.hx index 2b2ab1d46..e73976d8d 100644 --- a/Performance/PixelPerfectCollision/source/PlayState.hx +++ b/Performance/PixelPerfectCollision/source/PlayState.hx @@ -7,7 +7,6 @@ import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.math.FlxPoint; -import flixel.math.FlxVector; import flixel.math.FlxAngle; import flixel.util.FlxColor; import flixel.util.FlxCollision; diff --git a/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx b/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx index 36c4226bd..ea869566e 100644 --- a/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx +++ b/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx @@ -1,7 +1,7 @@ package entities; import flixel.FlxG; -import flixel.addons.display.FlxExtendedSprite; +import flixel.addons.display.FlxExtendedMouseSprite; import flixel.math.FlxRect; import haxe.Json; import haxe.io.Path; @@ -10,7 +10,7 @@ import openfl.Assets; /** * @author MrCdK */ -class Character extends FlxExtendedSprite +class Character extends FlxExtendedMouseSprite { public var collisionMap:FlxRect; public var maxBounds:FlxRect; diff --git a/Platformers/Mode/source/MenuState.hx b/Platformers/Mode/source/MenuState.hx index 3849e10b1..f407801c8 100644 --- a/Platformers/Mode/source/MenuState.hx +++ b/Platformers/Mode/source/MenuState.hx @@ -198,10 +198,10 @@ class MenuState extends FlxState { if (_demoMode) { - FlxG.vcr.loadReplay(Assets.getText('assets/data/demo${FlxG.random.int(1, 2)}.fgr'), new PlayState(), ["ANY"], 22, onDemoComplete); + FlxG.vcr.loadReplay(Assets.getText('assets/data/demo${FlxG.random.int(1, 2)}.fgr'), PlayState.new, ["ANY"], 22, onDemoComplete); } else - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } /** diff --git a/Platformers/Mode/source/PlayState.hx b/Platformers/Mode/source/PlayState.hx index 18a9b148b..82066eaff 100644 --- a/Platformers/Mode/source/PlayState.hx +++ b/Platformers/Mode/source/PlayState.hx @@ -341,7 +341,7 @@ class PlayState extends FlxState // Escape to the main menu #if FLX_KEYBOARD if (FlxG.keys.pressed.ESCAPE) - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); #end } @@ -363,7 +363,7 @@ class PlayState extends FlxState { // Reset the sounds for going inbetween the menu etc FlxG.sound.destroy(true); - FlxG.switchState(new VictoryState()); + FlxG.switchState(VictoryState.new); } /** diff --git a/Platformers/Mode/source/Player.hx b/Platformers/Mode/source/Player.hx index f94fdacd6..122753247 100644 --- a/Platformers/Mode/source/Player.hx +++ b/Platformers/Mode/source/Player.hx @@ -297,7 +297,7 @@ class Player extends FlxSprite } } -@:enum abstract Animation(String) to String +enum abstract Animation(String) to String { var IDLE = "idle"; var IDLE_UP = "idle_up"; diff --git a/Platformers/Mode/source/VictoryState.hx b/Platformers/Mode/source/VictoryState.hx index 42ce3d7ea..b68ad0c67 100644 --- a/Platformers/Mode/source/VictoryState.hx +++ b/Platformers/Mode/source/VictoryState.hx @@ -54,7 +54,7 @@ class VictoryState extends FlxState FlxG.sound.play(FlxAssets.getSound("assets/sounds/menu_hit_2")); FlxG.cameras.fade(0xff131c1b, 2, false, function() { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); }); } } diff --git a/Platformers/ProjectJumper/source/MenuState.hx b/Platformers/ProjectJumper/source/MenuState.hx index 4280b6495..2cdd03957 100644 --- a/Platformers/ProjectJumper/source/MenuState.hx +++ b/Platformers/ProjectJumper/source/MenuState.hx @@ -126,7 +126,7 @@ class MenuState extends FlxState function startGame():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } diff --git a/Platformers/ProjectJumper/source/PlayState.hx b/Platformers/ProjectJumper/source/PlayState.hx index 92565a78c..a2244c20d 100644 --- a/Platformers/ProjectJumper/source/PlayState.hx +++ b/Platformers/ProjectJumper/source/PlayState.hx @@ -143,7 +143,7 @@ class PlayState extends FlxState if (_restart) { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } diff --git a/Platformers/Revenge/source/EndState.hx b/Platformers/Revenge/source/EndState.hx index 6d80065c1..0265d7335 100644 --- a/Platformers/Revenge/source/EndState.hx +++ b/Platformers/Revenge/source/EndState.hx @@ -72,6 +72,6 @@ class EndState extends FlxState function onFade():Void { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } } diff --git a/Platformers/Revenge/source/MenuState.hx b/Platformers/Revenge/source/MenuState.hx index c0ff55fe5..b129193c1 100644 --- a/Platformers/Revenge/source/MenuState.hx +++ b/Platformers/Revenge/source/MenuState.hx @@ -80,7 +80,7 @@ class MenuState extends FlxState function onFade():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } function onStartOver():Void diff --git a/Platformers/Revenge/source/PlayState.hx b/Platformers/Revenge/source/PlayState.hx index 2ba561754..172988e46 100644 --- a/Platformers/Revenge/source/PlayState.hx +++ b/Platformers/Revenge/source/PlayState.hx @@ -177,6 +177,6 @@ class PlayState extends FlxState function onFade():Void { // FlxG.fade.start also takes in a callback which is called after the fade ends!! - FlxG.switchState(new EndState()); + FlxG.switchState(EndState.new); } } diff --git a/Tutorials/TurnBasedRPG/source/CombatHUD.hx b/Tutorials/TurnBasedRPG/source/CombatHUD.hx index 28485e5e4..07eb8b5a2 100644 --- a/Tutorials/TurnBasedRPG/source/CombatHUD.hx +++ b/Tutorials/TurnBasedRPG/source/CombatHUD.hx @@ -8,7 +8,7 @@ import flixel.FlxSprite; import flixel.addons.effects.chainable.FlxEffectSprite; import flixel.addons.effects.chainable.FlxWaveEffect; import flixel.group.FlxGroup.FlxTypedGroup; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; diff --git a/Tutorials/TurnBasedRPG/source/Enemy.hx b/Tutorials/TurnBasedRPG/source/Enemy.hx index 39c79daed..db26ef240 100644 --- a/Tutorials/TurnBasedRPG/source/Enemy.hx +++ b/Tutorials/TurnBasedRPG/source/Enemy.hx @@ -4,7 +4,7 @@ import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; import flixel.math.FlxVelocity; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; using flixel.util.FlxSpriteUtil; @@ -22,7 +22,7 @@ class Enemy extends FlxSprite var brain:FSM; var idleTimer:Float; var moveDirection:Float; - var stepSound:FlxSound; + var stepSound:FlxSound; public var type(default, null):EnemyType; public var seesPlayer:Bool; diff --git a/Tutorials/TurnBasedRPG/source/GameOverState.hx b/Tutorials/TurnBasedRPG/source/GameOverState.hx index fe825ed6e..f824af731 100644 --- a/Tutorials/TurnBasedRPG/source/GameOverState.hx +++ b/Tutorials/TurnBasedRPG/source/GameOverState.hx @@ -10,8 +10,6 @@ import flixel.util.FlxColor; class GameOverState extends FlxState { - var score:Int = 0; // number of coins we've collected - var win:Bool; // if we won or lost var titleText:FlxText; // the title text var messageText:FlxText; // the final score message text var scoreIcon:FlxSprite; // sprite for a coin icon @@ -27,12 +25,7 @@ class GameOverState extends FlxState public function new(win:Bool, score:Int) { super(); - this.win = win; - this.score = score; - } - override public function create() - { #if FLX_MOUSE FlxG.mouse.visible = true; #end @@ -71,8 +64,6 @@ class GameOverState extends FlxState add(mainMenuButton); FlxG.camera.fade(FlxColor.BLACK, 0.33, true); - - super.create(); } /** @@ -103,7 +94,7 @@ class GameOverState extends FlxState { FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function() { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); }); } } diff --git a/Tutorials/TurnBasedRPG/source/HUD.hx b/Tutorials/TurnBasedRPG/source/HUD.hx index 8db8bfc9a..09db963d2 100644 --- a/Tutorials/TurnBasedRPG/source/HUD.hx +++ b/Tutorials/TurnBasedRPG/source/HUD.hx @@ -2,7 +2,7 @@ package; import flixel.FlxG; import flixel.FlxSprite; -import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.group.FlxGroup; import flixel.text.FlxText; import flixel.util.FlxColor; diff --git a/Tutorials/TurnBasedRPG/source/MenuState.hx b/Tutorials/TurnBasedRPG/source/MenuState.hx index 8a8f5578c..29a71272d 100644 --- a/Tutorials/TurnBasedRPG/source/MenuState.hx +++ b/Tutorials/TurnBasedRPG/source/MenuState.hx @@ -57,7 +57,7 @@ class MenuState extends FlxState { FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function() { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); }); } @@ -65,7 +65,7 @@ class MenuState extends FlxState { FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function() { - FlxG.switchState(new OptionsState()); + FlxG.switchState(OptionsState.new); }); } diff --git a/Tutorials/TurnBasedRPG/source/OptionsState.hx b/Tutorials/TurnBasedRPG/source/OptionsState.hx index 23eec3da5..4a567f211 100644 --- a/Tutorials/TurnBasedRPG/source/OptionsState.hx +++ b/Tutorials/TurnBasedRPG/source/OptionsState.hx @@ -37,7 +37,8 @@ class OptionsState extends FlxState add(volumeText); // the volume buttons will be smaller than 'default' buttons - volumeDownButton = new FlxButton(8, volumeText.y + volumeText.height + 2, "-", clickVolumeDown); + volumeDownButton = new FlxButton(8, volumeText.y + volumeText.height + 2, "-", + clickVolumeDown); volumeDownButton.loadGraphic(AssetPaths.button__png, true, 20, 20); volumeDownButton.onUp.sound = FlxG.sound.load(AssetPaths.select__wav); add(volumeDownButton); @@ -47,7 +48,8 @@ class OptionsState extends FlxState volumeUpButton.onUp.sound = FlxG.sound.load(AssetPaths.select__wav); add(volumeUpButton); - volumeBar = new FlxBar(volumeDownButton.x + volumeDownButton.width + 4, volumeDownButton.y, LEFT_TO_RIGHT, Std.int(FlxG.width - 64), + volumeBar = new FlxBar(volumeDownButton.x + volumeDownButton.width + 4, + volumeDownButton.y, LEFT_TO_RIGHT, Std.int(FlxG.width - 64), Std.int(volumeUpButton.height)); volumeBar.createFilledBar(0xff464646, FlxColor.WHITE, true, FlxColor.WHITE); add(volumeBar); @@ -61,12 +63,14 @@ class OptionsState extends FlxState add(volumeAmountText); #if desktop - fullscreenButton = new FlxButton(0, volumeBar.y + volumeBar.height + 8, FlxG.fullscreen ? "FULLSCREEN" : "WINDOWED", clickFullscreen); + fullscreenButton = new FlxButton(0, volumeBar.y + volumeBar.height + 8, + FlxG.fullscreen ? "FULLSCREEN" : "WINDOWED", clickFullscreen); fullscreenButton.screenCenter(FlxAxes.X); add(fullscreenButton); #end - clearDataButton = new FlxButton((FlxG.width / 2) - 90, FlxG.height - 28, "Clear Data", clickClearData); + clearDataButton = new FlxButton((FlxG.width / 2) - 90, FlxG.height - 28, "Clear Data", + clickClearData); clearDataButton.onUp.sound = FlxG.sound.load(AssetPaths.select__wav); add(clearDataButton); @@ -109,7 +113,7 @@ class OptionsState extends FlxState FlxG.save.flush(); FlxG.camera.fade(FlxColor.BLACK, .33, false, function() { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); }); } diff --git a/Tutorials/TurnBasedRPG/source/PlayState.hx b/Tutorials/TurnBasedRPG/source/PlayState.hx index 399501fc6..b2a51962b 100644 --- a/Tutorials/TurnBasedRPG/source/PlayState.hx +++ b/Tutorials/TurnBasedRPG/source/PlayState.hx @@ -4,7 +4,7 @@ import flixel.FlxG; import flixel.FlxState; import flixel.addons.editors.ogmo.FlxOgmo3Loader; import flixel.group.FlxGroup.FlxTypedGroup; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import flixel.tile.FlxTilemap; import flixel.util.FlxColor; #if mobile @@ -159,7 +159,7 @@ class PlayState extends FlxState function doneFadeOut() { - FlxG.switchState(new GameOverState(won, money)); + FlxG.switchState(() -> new GameOverState(won, money)); } function playerTouchCoin(player:Player, coin:Coin) diff --git a/Tutorials/TurnBasedRPG/source/Player.hx b/Tutorials/TurnBasedRPG/source/Player.hx index 92c319b57..32a3186e6 100644 --- a/Tutorials/TurnBasedRPG/source/Player.hx +++ b/Tutorials/TurnBasedRPG/source/Player.hx @@ -3,7 +3,7 @@ package; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; class Player extends FlxSprite { diff --git a/UserInterface/FlxBitmapText/source/PlayState.hx b/UserInterface/FlxBitmapText/source/PlayState.hx index 75db9b4da..8a45bcc40 100644 --- a/UserInterface/FlxBitmapText/source/PlayState.hx +++ b/UserInterface/FlxBitmapText/source/PlayState.hx @@ -65,7 +65,7 @@ class PlayState extends FlxState tf2.letterSpacing = 25; tf2.autoUpperCase = true; tf2.multiLine = true; - tf2.wordWrap = false; + tf2.wrap = NONE; tf2.screenCenter(FlxAxes.X); add(tf2); @@ -80,7 +80,7 @@ class PlayState extends FlxState tf4.y = tf3.y + tf3.height + 50; tf4.alignment = FlxTextAlign.CENTER; tf4.text = "!\u20e4 You can e\u0332v\u0332e\u0332n\u0332 define and use\nUnicode Combining Diacritical Marks!"; - tf4.multiLine = true; + tf4.multiLine = true; tf4.screenCenter(FlxAxes.X); add(tf4); } diff --git a/UserInterface/RPGInterface/source/State_Battle.hx b/UserInterface/RPGInterface/source/State_Battle.hx index adafa1491..b87deaf1c 100644 --- a/UserInterface/RPGInterface/source/State_Battle.hx +++ b/UserInterface/RPGInterface/source/State_Battle.hx @@ -9,6 +9,11 @@ import openfl.events.Event; */ class State_Battle extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_battle"; @@ -76,7 +81,7 @@ class State_Battle extends FlxUIState case FlxUITypedButton.CLICK_EVENT: switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_CodeTest.hx b/UserInterface/RPGInterface/source/State_CodeTest.hx index 6c26d1582..797069933 100644 --- a/UserInterface/RPGInterface/source/State_CodeTest.hx +++ b/UserInterface/RPGInterface/source/State_CodeTest.hx @@ -15,6 +15,11 @@ import flixel.addons.ui.FlxUIState; */ class State_CodeTest extends FlxUIState { + public function new() + { + super(); + } + override public function create() { super.create(); @@ -36,7 +41,7 @@ class State_CodeTest extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_DefaultTest.hx b/UserInterface/RPGInterface/source/State_DefaultTest.hx index 7ef6e5972..f1b98607c 100644 --- a/UserInterface/RPGInterface/source/State_DefaultTest.hx +++ b/UserInterface/RPGInterface/source/State_DefaultTest.hx @@ -7,6 +7,11 @@ import flixel.addons.ui.FlxUIState; */ class State_DefaultTest extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_default"; @@ -27,7 +32,7 @@ class State_DefaultTest extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); case "popup": var popup:FlxUIPopup = new FlxUIPopup(); // create the popup popup.quickSetup // set it up diff --git a/UserInterface/RPGInterface/source/State_SaveMenu.hx b/UserInterface/RPGInterface/source/State_SaveMenu.hx index 4580acdcd..2bdbd9881 100644 --- a/UserInterface/RPGInterface/source/State_SaveMenu.hx +++ b/UserInterface/RPGInterface/source/State_SaveMenu.hx @@ -10,6 +10,11 @@ import haxe.xml.Access; */ class State_SaveMenu extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_save"; @@ -43,7 +48,7 @@ class State_SaveMenu extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_TestMenu.hx b/UserInterface/RPGInterface/source/State_TestMenu.hx index c30de315d..b34b721f7 100644 --- a/UserInterface/RPGInterface/source/State_TestMenu.hx +++ b/UserInterface/RPGInterface/source/State_TestMenu.hx @@ -6,6 +6,11 @@ import flixel.addons.ui.FlxUIState; */ class State_TestMenu extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_menu"; @@ -26,7 +31,7 @@ class State_TestMenu extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_Title.hx b/UserInterface/RPGInterface/source/State_Title.hx index e524812c9..79d72338f 100644 --- a/UserInterface/RPGInterface/source/State_Title.hx +++ b/UserInterface/RPGInterface/source/State_Title.hx @@ -8,6 +8,11 @@ import flixel.addons.ui.FlxUIState; */ class State_Title extends FlxUIState { + public function new() + { + super(); + } + override public function create():Void { FlxG.cameras.bgColor = 0xff131c1b; @@ -39,11 +44,11 @@ class State_Title extends FlxUIState { switch (Std.string(params[0])) { - case "saves": FlxG.switchState(new State_SaveMenu()); - case "menu": FlxG.switchState(new State_TestMenu()); - case "battle": FlxG.switchState(new State_Battle()); - case "default_test": FlxG.switchState(new State_DefaultTest()); - case "code_test": FlxG.switchState(new State_CodeTest()); + case "saves": FlxG.switchState(State_SaveMenu.new); + case "menu": FlxG.switchState(State_TestMenu.new); + case "battle": FlxG.switchState(State_Battle.new); + case "default_test": FlxG.switchState(State_DefaultTest.new); + case "code_test": FlxG.switchState(State_CodeTest.new); case "popup": openSubState(new Popup_Demo()); } } @@ -58,6 +63,6 @@ class State_Title extends FlxUIState function reloadState():Void { - FlxG.switchState(new State_Title()); + FlxG.switchState(State_Title.new); } } diff --git a/UserInterface/Tooltips/source/State_Demo.hx b/UserInterface/Tooltips/source/State_Demo.hx index b0e8dd7b7..3f8df7927 100644 --- a/UserInterface/Tooltips/source/State_Demo.hx +++ b/UserInterface/Tooltips/source/State_Demo.hx @@ -7,6 +7,11 @@ import flixel.addons.ui.FlxUIState; */ class State_Demo extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_menu"; @@ -22,11 +27,11 @@ class State_Demo extends FlxUIState var str:String = (params != null && params.length >= 1) ? cast params[0] : ""; if (str == "defaults") { - FlxG.switchState(new State_Demo2()); + FlxG.switchState(State_Demo2.new); } if (str == "hand_code") { - FlxG.switchState(new State_DemoCode()); + FlxG.switchState(State_DemoCode.new); } } } @@ -37,7 +42,7 @@ class State_Demo extends FlxUIState #if debug if (FlxG.keys.justPressed.R) { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); } #end } diff --git a/UserInterface/Tooltips/source/State_Demo2.hx b/UserInterface/Tooltips/source/State_Demo2.hx index 37cb2a704..4f4c31cd7 100644 --- a/UserInterface/Tooltips/source/State_Demo2.hx +++ b/UserInterface/Tooltips/source/State_Demo2.hx @@ -29,11 +29,11 @@ class State_Demo2 extends FlxUIState var str:String = (params != null && params.length >= 1) ? cast params[0] : ""; if (str == "no_defaults") { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); } if (str == "hand_code") { - FlxG.switchState(new State_DemoCode()); + FlxG.switchState(State_DemoCode.new); } } } diff --git a/UserInterface/Tooltips/source/State_DemoCode.hx b/UserInterface/Tooltips/source/State_DemoCode.hx index 1eacd0f7f..94c67ddc4 100644 --- a/UserInterface/Tooltips/source/State_DemoCode.hx +++ b/UserInterface/Tooltips/source/State_DemoCode.hx @@ -19,6 +19,11 @@ import openfl.text.TextFormatAlign; */ class State_DemoCode extends FlxUIState { + public function new() + { + super(); + } + override public function create() { super.create(); @@ -34,11 +39,11 @@ class State_DemoCode extends FlxUIState var str:String = (params != null && params.length >= 1) ? cast params[0] : ""; if (str == "defaults") { - FlxG.switchState(new State_Demo2()); + FlxG.switchState(State_Demo2.new); } if (str == "no_defaults") { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); } } } @@ -71,30 +76,33 @@ class State_DemoCode extends FlxUIState {bodyWidth: 100}); b = addBtn("even_fancier", new FlxUIButton(b.x, b.y + b.height + 10, "Even fancier"), "Even fancier tooltip!", - "This tooltip has a title and a body, as well as custom padding and offsets", null, - {titleWidth: 120, bodyWidth: 120, bodyOffset: new FlxPoint(5, 5)}); + "This tooltip has a title and a body, as well as custom padding and offsets", null, { + titleWidth: 120, + bodyWidth: 120, + bodyOffset: new FlxPoint(5, 5) + }); b = addBtn("fanciest", new FlxUIButton(b.x, b.y + b.height + 10, "Fanciest"), "Fanciest tooltip", "This tooltip has a title and a body, custom padding and offsets, as well as custom text formatting", null, { - titleWidth: 125, - bodyWidth: 120, - bodyOffset: new FlxPoint(5, 5), - titleFormat: sans12, - bodyFormat: sans10, - titleBorder: border, - bodyBorder: border, - leftPadding: 5, - rightPadding: 5, - topPadding: 5, - bottomPadding: 5, - background: FlxColor.RED, - borderSize: 1, - borderColor: FlxColor.WHITE - }); + titleWidth: 125, + bodyWidth: 120, + bodyOffset: new FlxPoint(5, 5), + titleFormat: sans12, + bodyFormat: sans10, + titleBorder: border, + bodyBorder: border, + leftPadding: 5, + rightPadding: 5, + topPadding: 5, + bottomPadding: 5, + background: FlxColor.RED, + borderSize: 1, + borderColor: FlxColor.WHITE + }); b = addBtn("goback", new FlxUIButton(b.x, b.y + b.height + 10, "Go Back", function() { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); }), "Go Back", "This button takes you back to the first screen"); } From 58a8e56f8ee3624f7f8663ac9db9168658c8738d Mon Sep 17 00:00:00 2001 From: Starmapo Date: Wed, 6 Mar 2024 12:56:28 -0400 Subject: [PATCH 3/5] Removed legacy PostProcess demo (#332) - Removed `FlxG.bitmap.dumpCache` call in TexturePackerAtlas demo --- .vscode/settings.json | 1 - .../TexturePackerAtlas/source/MenuState.hx | 3 - Effects/PostProcess/PostProcess.hxproj | 75 ---------- Effects/PostProcess/Project.xml | 85 ----------- Effects/PostProcess/assets/images/logo.png | Bin 4002 -> 0 bytes Effects/PostProcess/assets/shaders/blur.frag | 47 ------ .../assets/shaders/deuteranopia.frag | 16 -- Effects/PostProcess/assets/shaders/grain.frag | 141 ------------------ .../PostProcess/assets/shaders/grayscale.frag | 13 -- Effects/PostProcess/assets/shaders/hq2x.frag | 25 ---- .../PostProcess/assets/shaders/invert.frag | 12 -- .../assets/shaders/protanopia.frag | 16 -- .../PostProcess/assets/shaders/scanline.frag | 17 --- .../PostProcess/assets/shaders/tiltshift.frag | 82 ---------- .../assets/shaders/tritanopia.frag | 16 -- Effects/PostProcess/source/Main.hx | 13 -- Effects/PostProcess/source/PlayState.hx | 54 ------- flixel-demos.code-workspace | 3 - 18 files changed, 619 deletions(-) delete mode 100644 Effects/PostProcess/PostProcess.hxproj delete mode 100644 Effects/PostProcess/Project.xml delete mode 100644 Effects/PostProcess/assets/images/logo.png delete mode 100644 Effects/PostProcess/assets/shaders/blur.frag delete mode 100644 Effects/PostProcess/assets/shaders/deuteranopia.frag delete mode 100644 Effects/PostProcess/assets/shaders/grain.frag delete mode 100644 Effects/PostProcess/assets/shaders/grayscale.frag delete mode 100644 Effects/PostProcess/assets/shaders/hq2x.frag delete mode 100644 Effects/PostProcess/assets/shaders/invert.frag delete mode 100644 Effects/PostProcess/assets/shaders/protanopia.frag delete mode 100644 Effects/PostProcess/assets/shaders/scanline.frag delete mode 100644 Effects/PostProcess/assets/shaders/tiltshift.frag delete mode 100644 Effects/PostProcess/assets/shaders/tritanopia.frag delete mode 100644 Effects/PostProcess/source/Main.hx delete mode 100644 Effects/PostProcess/source/PlayState.hx diff --git a/.vscode/settings.json b/.vscode/settings.json index bc601fbda..6c6ac02a6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,7 +37,6 @@ "Effects/FlxTween/source", "Effects/MosaicEffect/source", "Effects/Parallax/source", - "Effects/PostProcess/source", "Effects/Transitions/source", "Features/CollisionAndGrouping/source", "Features/Colors/source", diff --git a/Editors/TexturePackerAtlas/source/MenuState.hx b/Editors/TexturePackerAtlas/source/MenuState.hx index bf2e0e266..6b373a32b 100644 --- a/Editors/TexturePackerAtlas/source/MenuState.hx +++ b/Editors/TexturePackerAtlas/source/MenuState.hx @@ -123,8 +123,5 @@ class MenuState extends FlxState x11.animation.addByPrefix("spin", "", 3); x11.animation.play("spin"); add(x11); - - // Remove atlas bitmaps from memory (useful for targets with hardware acceleration: cpp only atm). - FlxG.bitmap.dumpCache(); } } diff --git a/Effects/PostProcess/PostProcess.hxproj b/Effects/PostProcess/PostProcess.hxproj deleted file mode 100644 index d864fb9a8..000000000 --- a/Effects/PostProcess/PostProcess.hxproj +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb - - - - - - - - \ No newline at end of file diff --git a/Effects/PostProcess/Project.xml b/Effects/PostProcess/Project.xml deleted file mode 100644 index f965e2824..000000000 --- a/Effects/PostProcess/Project.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Effects/PostProcess/assets/images/logo.png b/Effects/PostProcess/assets/images/logo.png deleted file mode 100644 index e939189a27b16f905844a6a6ac1dec96f7e0283b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4002 zcmV;T4_)wyP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000EdNkl6+1-h)7OeRZuTp z0-j6vTtovNghFBIscfm8q{~vlO!n0C97OO^f{=zrgy^_DH z69Om57$#5wvtMk~hUG?p0RlHj5@y@2i2rK(sDcfG28iG@%>Mb?1r=wB?1L-_Lji&& z2>tvk1?x z-LxPWFxb`-u&pKXC@f1DSwLY~!=R4BvWStKdtZEDL1fP6)61zbD58)8X+OQh1wj#o znSenFg_(ju1%;V}K>>xChJhW0nTUZIg_(+h6@@{^4NS!t%@5zaj|k+MTQeDBG@t+I z;Q(QbG3a=0lQA%%9D?+g^RNCAH5LO2N;Li-x?BBP2gb(l7tvtoMj4j;wcFn-)VkN;La&*^XO~xxrJyP=zwHj`0TXwJgRo z%HP#>wRIeU9R3WBEXMJ<{PVlQQO>MmyunvLwiuF8O8ze2i;n`Hb7cubG|GOl!S_-U zY`YbUAqQnxZUpna9^CadEQWX#?m8wm_<_X`hcb5^iRWBRiy;nW?m8wm_}$YW1|1hF zk1rU9!HcqR9ci9(nU2AOBBYMQbFQ|KLs{&F4YxVa0yvDN!D+UzbPU`7Nr4f@;Pm1^Y8}Zbe)YftoQ5$Pk(HcOhehGQ z5M9ZvIxI>`43U+bRfk1Mi6N?zG<6t_k`_ZmB|LQ)iNcGqXeGRLn1u3L@FhRSB9+Wr zM{>@8|4TM8I^WI*u}CG0)RCMw?|f%57Og}?9a%&Xh7rb)>&2VO>&Oy{NQ}|2J`|MK zkp&bP7)}^NE<9*!se>|#ER0l@$gG1RifoKCE0J9XB@`7Hr&gk>j^w=Y(`UwG%&bIZ z9iw^g!++uRU)PPsII$8Pbznr%g)vo$jykZR=)^dxM0XunP%vN|f#|M7HwqRECyW72 z9lB63VK`w7sOnISf(_#k1R=&~mOuGR+MO?q80bM{UBttRK>|cH%DL^kXfeouh(bBH zb00MZDUd}`C}5BSnHPl$21yWJ6iOImLDHg7!ypZE)D2%K0Ng09&lT{ blur by one pixel - //2.0 -> blur by two pixels, etc. - float blur = radius / uResolution.x; - - //the direction of our blur - //(1.0, 0.0) -> x-axis blur - //(0.0, 1.0) -> y-axis blur - float hstep = dirx; - float vstep = diry; - - //apply blurring, using a 9-tap filter with predefined gaussian weights - - sum += texture2D(uImage0, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162; - sum += texture2D(uImage0, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541; - sum += texture2D(uImage0, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216; - sum += texture2D(uImage0, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946; - - sum += texture2D(uImage0, vec2(tc.x, tc.y)) * 0.2270270270; - - sum += texture2D(uImage0, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946; - sum += texture2D(uImage0, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216; - sum += texture2D(uImage0, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541; - sum += texture2D(uImage0, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162; - - //discard alpha for our simple demo, multiply by vertex color and return - gl_FragColor = vec4(sum.rgb, 1.0); -} diff --git a/Effects/PostProcess/assets/shaders/deuteranopia.frag b/Effects/PostProcess/assets/shaders/deuteranopia.frag deleted file mode 100644 index 3497e796e..000000000 --- a/Effects/PostProcess/assets/shaders/deuteranopia.frag +++ /dev/null @@ -1,16 +0,0 @@ -// -// Deuteranopia color blindness simulation -// Simple passthrough fragment shader -// -uniform sampler2D uImage0; -varying vec2 vTexCoord; - -const mat4 mDeuteranopia = mat4( 0.43 , 0.72 , -0.15 , 0.0 , - 0.34 , 0.57 , 0.09 , 0.0 , - -0.02 , 0.03 , 1.00 , 0.0 , - 0.0 , 0.0 , 0.0 , 1.0 ); - -void main() -{ - gl_FragColor = mDeuteranopia * texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/assets/shaders/grain.frag b/Effects/PostProcess/assets/shaders/grain.frag deleted file mode 100644 index 5f0163195..000000000 --- a/Effects/PostProcess/assets/shaders/grain.frag +++ /dev/null @@ -1,141 +0,0 @@ -/* -Film Grain post-process shader v1.1 -Martins Upitis (martinsh) devlog-martinsh.blogspot.com -2013 - --------------------------- -This work is licensed under a Creative Commons Attribution 3.0 Unported License. -So you are free to share, modify and adapt it for your needs, and even use it for commercial use. -I would also love to hear about a project you are using it. - -Have fun, -Martins --------------------------- - -Perlin noise shader by toneburst: -http://machinesdontcare.wordpress.com/2009/06/25/3d-perlin-noise-sphere-vertex-shader-sourcecode/ -*/ - -uniform sampler2D uImage0; //rendered scene sampler -uniform vec2 uResolution; //scene sampler resolution -uniform float uTime; - -varying vec2 vTexCoord; - -const float permTexUnit = 1.0/256.0; // Perm texture texel-size -const float permTexUnitHalf = 0.5/256.0; // Half perm texture texel-size - -float width = uResolution.x; -float height = uResolution.y; - -const float grainamount = 0.05; //grain amount -bool colored = false; //colored noise? -float coloramount = 0.6; -float grainsize = 1.6; //grain particle size (1.5 - 2.5) -float lumamount = 1.0; // - -//a random texture generator, but you can also use a pre-computed perturbation texture -vec4 rnm(in vec2 tc) -{ - float noise = sin(dot(tc + vec2(uTime,uTime),vec2(12.9898,78.233))) * 43758.5453; - - float noiseR = fract(noise)*2.0-1.0; - float noiseG = fract(noise*1.2154)*2.0-1.0; - float noiseB = fract(noise*1.3453)*2.0-1.0; - float noiseA = fract(noise*1.3647)*2.0-1.0; - - return vec4(noiseR,noiseG,noiseB,noiseA); -} - -float fade(in float t) { - return t*t*t*(t*(t*6.0-15.0)+10.0); -} - -float pnoise3D(in vec3 p) -{ - vec3 pi = permTexUnit*floor(p)+permTexUnitHalf; // Integer part, scaled so +1 moves permTexUnit texel - // and offset 1/2 texel to sample texel centers - vec3 pf = fract(p); // Fractional part for interpolation - - // Noise contributions from (x=0, y=0), z=0 and z=1 - float perm00 = rnm(pi.xy).a ; - vec3 grad000 = rnm(vec2(perm00, pi.z)).rgb * 4.0 - 1.0; - float n000 = dot(grad000, pf); - vec3 grad001 = rnm(vec2(perm00, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n001 = dot(grad001, pf - vec3(0.0, 0.0, 1.0)); - - // Noise contributions from (x=0, y=1), z=0 and z=1 - float perm01 = rnm(pi.xy + vec2(0.0, permTexUnit)).a ; - vec3 grad010 = rnm(vec2(perm01, pi.z)).rgb * 4.0 - 1.0; - float n010 = dot(grad010, pf - vec3(0.0, 1.0, 0.0)); - vec3 grad011 = rnm(vec2(perm01, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n011 = dot(grad011, pf - vec3(0.0, 1.0, 1.0)); - - // Noise contributions from (x=1, y=0), z=0 and z=1 - float perm10 = rnm(pi.xy + vec2(permTexUnit, 0.0)).a ; - vec3 grad100 = rnm(vec2(perm10, pi.z)).rgb * 4.0 - 1.0; - float n100 = dot(grad100, pf - vec3(1.0, 0.0, 0.0)); - vec3 grad101 = rnm(vec2(perm10, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n101 = dot(grad101, pf - vec3(1.0, 0.0, 1.0)); - - // Noise contributions from (x=1, y=1), z=0 and z=1 - float perm11 = rnm(pi.xy + vec2(permTexUnit, permTexUnit)).a ; - vec3 grad110 = rnm(vec2(perm11, pi.z)).rgb * 4.0 - 1.0; - float n110 = dot(grad110, pf - vec3(1.0, 1.0, 0.0)); - vec3 grad111 = rnm(vec2(perm11, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n111 = dot(grad111, pf - vec3(1.0, 1.0, 1.0)); - - // Blend contributions along x - vec4 n_x = mix(vec4(n000, n001, n010, n011), vec4(n100, n101, n110, n111), fade(pf.x)); - - // Blend contributions along y - vec2 n_xy = mix(n_x.xy, n_x.zw, fade(pf.y)); - - // Blend contributions along z - float n_xyz = mix(n_xy.x, n_xy.y, fade(pf.z)); - - // We're done, return the final noise value. - return n_xyz; -} - -//2d coordinate orientation thing -vec2 coordRot(in vec2 tc, in float angle) -{ - float aspect = width/height; - float rotX = ((tc.x*2.0-1.0)*aspect*cos(angle)) - ((tc.y*2.0-1.0)*sin(angle)); - float rotY = ((tc.y*2.0-1.0)*cos(angle)) + ((tc.x*2.0-1.0)*aspect*sin(angle)); - rotX = ((rotX/aspect)*0.5+0.5); - rotY = rotY*0.5+0.5; - return vec2(rotX,rotY); -} - -void main() -{ - vec2 texCoord = vTexCoord.st; - - vec3 rotOffset = vec3(1.425,3.892,5.835); //rotation offset values - vec2 rotCoordsR = coordRot(texCoord, uTime + rotOffset.x); - vec3 noise = vec3(pnoise3D(vec3(rotCoordsR*vec2(width/grainsize,height/grainsize),0.0))); - - if (colored) - { - vec2 rotCoordsG = coordRot(texCoord, uTime + rotOffset.y); - vec2 rotCoordsB = coordRot(texCoord, uTime + rotOffset.z); - noise.g = mix(noise.r,pnoise3D(vec3(rotCoordsG*vec2(width/grainsize,height/grainsize),1.0)),coloramount); - noise.b = mix(noise.r,pnoise3D(vec3(rotCoordsB*vec2(width/grainsize,height/grainsize),2.0)),coloramount); - } - - vec3 col = texture2D(uImage0, texCoord).rgb; - - //noisiness response curve based on scene luminance - vec3 lumcoeff = vec3(0.299,0.587,0.114); - float luminance = mix(0.0,dot(col, lumcoeff),lumamount); - float lum = smoothstep(0.2,0.0,luminance); - lum += luminance; - - - noise = mix(noise,vec3(0.0),pow(lum,4.0)); - col = col+noise*grainamount; - - gl_FragColor = vec4(col,1.0); -} diff --git a/Effects/PostProcess/assets/shaders/grayscale.frag b/Effects/PostProcess/assets/shaders/grayscale.frag deleted file mode 100644 index d8dffa86b..000000000 --- a/Effects/PostProcess/assets/shaders/grayscale.frag +++ /dev/null @@ -1,13 +0,0 @@ -#ifdef GL_ES - precision mediump float; -#endif - -varying vec2 vTexCoord; -uniform sampler2D uImage0; - -void main(void) -{ - vec4 color = texture2D(uImage0, vTexCoord); - float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114)); - gl_FragColor = vec4(gray, gray, gray, 1.0); -} diff --git a/Effects/PostProcess/assets/shaders/hq2x.frag b/Effects/PostProcess/assets/shaders/hq2x.frag deleted file mode 100644 index 9f4854dd7..000000000 --- a/Effects/PostProcess/assets/shaders/hq2x.frag +++ /dev/null @@ -1,25 +0,0 @@ -uniform sampler2D uImage0; -uniform vec2 uResolution; - -varying vec2 vTexCoord; - -void main() -{ - float x = 1.0 / uResolution.x; - float y = 1.0 / uResolution.y; - - vec4 color1 = texture2D(uImage0, vTexCoord.st + vec2(-x, -y)); - vec4 color2 = texture2D(uImage0, vTexCoord.st + vec2(0.0, -y)); - vec4 color3 = texture2D(uImage0, vTexCoord.st + vec2(x, -y)); - - vec4 color4 = texture2D(uImage0, vTexCoord.st + vec2(-x, 0.0)); - vec4 color5 = texture2D(uImage0, vTexCoord.st + vec2(0.0, 0.0)); - vec4 color6 = texture2D(uImage0, vTexCoord.st + vec2(x, 0.0)); - - vec4 color7 = texture2D(uImage0, vTexCoord.st + vec2(-x, y)); - vec4 color8 = texture2D(uImage0, vTexCoord.st + vec2(0.0, y)); - vec4 color9 = texture2D(uImage0, vTexCoord.st + vec2(x, y)); - vec4 avg = color1 + color2 + color3 + color4 + color5 + color6 + color7 + color8 + color9; - - gl_FragColor = avg / 9.0; -} diff --git a/Effects/PostProcess/assets/shaders/invert.frag b/Effects/PostProcess/assets/shaders/invert.frag deleted file mode 100644 index 027fcec4b..000000000 --- a/Effects/PostProcess/assets/shaders/invert.frag +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef GL_ES - precision mediump float; -#endif - -varying vec2 vTexCoord; -uniform sampler2D uImage0; - -void main(void) -{ - vec4 color = texture2D(uImage0, vTexCoord); - gl_FragColor = vec4(vec3(1.0, 1.0, 1.0) - color.rgb, color.a); -} diff --git a/Effects/PostProcess/assets/shaders/protanopia.frag b/Effects/PostProcess/assets/shaders/protanopia.frag deleted file mode 100644 index 709ffe4f9..000000000 --- a/Effects/PostProcess/assets/shaders/protanopia.frag +++ /dev/null @@ -1,16 +0,0 @@ -// -// Protanopia color blindness simulation -// Simple passthrough fragment shader -// -uniform sampler2D uImage0; -varying vec2 vTexCoord; - -const mat4 mProtanopia = mat4( 0.20 , 0.99 , -0.19 , 0.0 , - 0.16 , 0.79 , 0.04 , 0.0 , - 0.01 , -0.01 , 1.00 , 0.0 , - 0.0 , 0.0 , 0.0 , 1.0 ); - -void main() -{ - gl_FragColor = mProtanopia * texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/assets/shaders/scanline.frag b/Effects/PostProcess/assets/shaders/scanline.frag deleted file mode 100644 index dbb52cfcf..000000000 --- a/Effects/PostProcess/assets/shaders/scanline.frag +++ /dev/null @@ -1,17 +0,0 @@ -#ifdef GL_ES - precision mediump float; -#endif - -varying vec2 vTexCoord; -uniform vec2 uResolution; -uniform sampler2D uImage0; - -const float scale = 1.0; - -void main() -{ - if (mod(floor(vTexCoord.y * uResolution.y / scale), 2.0) == 0.0) - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - else - gl_FragColor = texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/assets/shaders/tiltshift.frag b/Effects/PostProcess/assets/shaders/tiltshift.frag deleted file mode 100644 index 350640b0c..000000000 --- a/Effects/PostProcess/assets/shaders/tiltshift.frag +++ /dev/null @@ -1,82 +0,0 @@ -// Modified version of a tilt shift shader from Martin Jonasson (http://grapefrukt.com/) -// Read http://notes.underscorediscovery.com/ for context on shaders and this file -// License : MIT - -uniform sampler2D uImage0; -varying vec2 vTexCoord; - - /* - Take note that blurring in a single pass (the two for loops below) is more expensive than separating - the x and the y blur into different passes. This was used where bleeding edge performance - was not crucial and is to illustrate a point. - - The reason two passes is cheaper? - texture2D is a fairly high cost call, sampling a texture. - - So, in a single pass, like below, there are 3 steps, per x and y. - - That means a total of 9 "taps", it touches the texture to sample 9 times. - - Now imagine we apply this to some geometry, that is equal to 16 pixels on screen (tiny) - (16 * 16) * 9 = 2304 samples taken, for width * height number of pixels, * 9 taps - Now, if you split them up, it becomes 3 for x, and 3 for y, a total of 6 taps - (16 * 16) * 6 = 1536 samples - - That's on a *tiny* sprite, let's scale that up to 128x128 sprite... - (128 * 128) * 9 = 147,456 - (128 * 128) * 6 = 98,304 - - That's 33.33..% cheaper for splitting them up. - That's with 3 steps, with higher steps (more taps per pass...) - - A really smooth, 6 steps, 6*6 = 36 taps for one pass, 12 taps for two pass - You will notice, the curve is not linear, at 12 steps it's 144 vs 24 taps - It becomes orders of magnitude slower to do single pass! - Therefore, you split them up into two passes, one for x, one for y. - */ - - //I am hardcoding the constants like a jerk - -const float bluramount = 1.0; -const float center = 1.0; -const float stepSize = 0.004; -const float steps = 3.0; - -const float minOffs = (float(steps-1.0)) / -2.0; -const float maxOffs = (float(steps-1.0)) / +2.0; - -void main() { - - float amount; - vec4 blurred; - - //Work out how much to blur based on the mid point - amount = pow((vTexCoord.y * center) * 2.0 - 1.0, 2.0) * bluramount; - - //This is the accumulation of color from the surrounding pixels in the texture - blurred = vec4(0.0, 0.0, 0.0, 1.0); - - //From minimum offset to maximum offset - for (float offsX = minOffs; offsX <= maxOffs; ++offsX) { - for (float offsY = minOffs; offsY <= maxOffs; ++offsY) { - - //copy the coord so we can mess with it - vec2 temp_tcoord = vTexCoord.xy; - - //work out which uv we want to sample now - temp_tcoord.x += offsX * amount * stepSize; - temp_tcoord.y += offsY * amount * stepSize; - - //accumulate the sample - blurred += texture2D(uImage0, temp_tcoord); - - } //for y - } //for x - - //because we are doing an average, we divide by the amount (x AND y, hence steps * steps) - blurred /= float(steps * steps); - - //return the final blurred color - gl_FragColor = blurred; - -} //main diff --git a/Effects/PostProcess/assets/shaders/tritanopia.frag b/Effects/PostProcess/assets/shaders/tritanopia.frag deleted file mode 100644 index 6ec38e492..000000000 --- a/Effects/PostProcess/assets/shaders/tritanopia.frag +++ /dev/null @@ -1,16 +0,0 @@ -// -// Tritanopia color blindness simulation -// Simple passthrough fragment shader -// -uniform sampler2D uImage0; -varying vec2 vTexCoord; - -const mat4 mTritanopia = mat4( 0.97 , 0.11 , -0.08 , 0.0 , - 0.02 , 0.82 , 0.16 , 0.0 , - -0.06 , 0.88 , 0.18 , 0.0 , - 0.0 , 0.0 , 0.0 , 1.0 ); - -void main() -{ - gl_FragColor = mTritanopia * texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/source/Main.hx b/Effects/PostProcess/source/Main.hx deleted file mode 100644 index 9ba757312..000000000 --- a/Effects/PostProcess/source/Main.hx +++ /dev/null @@ -1,13 +0,0 @@ -package; - -import flixel.FlxGame; -import openfl.display.Sprite; - -class Main extends Sprite -{ - public function new() - { - super(); - addChild(new FlxGame(640, 480, PlayState)); - } -} diff --git a/Effects/PostProcess/source/PlayState.hx b/Effects/PostProcess/source/PlayState.hx deleted file mode 100644 index 6d13f1cb8..000000000 --- a/Effects/PostProcess/source/PlayState.hx +++ /dev/null @@ -1,54 +0,0 @@ -package; - -import flixel.addons.display.FlxBackdrop; -import flixel.addons.ui.FlxUIAssets; -import flixel.addons.ui.FlxUICheckBox; -import flixel.effects.postprocess.PostProcess; -import flixel.FlxG; -import flixel.FlxState; - -class PlayState extends FlxState -{ - var shaderNames:Array = [ - "blur", "tiltshift", "deuteranopia", "grain", "grayscale", "hq2x", "invert", "protanopia", "scanline", "tritanopia" - ]; - - var fragmentShaders:Array = []; - - override public function create():Void - { - var backdrop = new FlxBackdrop("assets/images/logo.png"); - backdrop.velocity.set(150, 150); - add(backdrop); - - var x = 10; - var y = 10; - - for (i in 0...shaderNames.length) - { - fragmentShaders.push(new PostProcess("assets/shaders/" + shaderNames[i] + ".frag")); - - createCheckbox(x, y, shaderNames[i], fragmentShaders[i]); - y += 25; - } - - // some shaders have properties that can be manipulated at runtime - var blurShader = fragmentShaders[0]; - blurShader.setUniform("diry", 1); - blurShader.setUniform("dirx", 1); - blurShader.setUniform("radius", 1); - } - - function createCheckbox(x:Float, y:Float, name:String, shader:PostProcess) - { - var checkbox = new FlxUICheckBox(x, y, FlxUIAssets.IMG_CHECK_BOX, FlxUIAssets.IMG_CHECK_MARK, name); - checkbox.callback = function() - { - if (checkbox.checked) - FlxG.addPostProcess(shader); - else - FlxG.removePostProcess(shader); - } - add(checkbox); - } -} diff --git a/flixel-demos.code-workspace b/flixel-demos.code-workspace index f169fda84..64e40146f 100644 --- a/flixel-demos.code-workspace +++ b/flixel-demos.code-workspace @@ -84,9 +84,6 @@ { "path": "Effects/Parallax" }, - { - "path": "Effects/PostProcess" - }, { "path": "Effects/Transitions" }, From a1c877d34ca9cb94e655725ff7517b5e98af571f Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Mon, 18 Mar 2024 10:22:26 -0700 Subject: [PATCH 4/5] use FlxButton (#333) --- Arcade/MinimalistTD/source/Button.hx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Arcade/MinimalistTD/source/Button.hx b/Arcade/MinimalistTD/source/Button.hx index 1918fa02e..09759c6e6 100644 --- a/Arcade/MinimalistTD/source/Button.hx +++ b/Arcade/MinimalistTD/source/Button.hx @@ -1,7 +1,12 @@ package; -import flixel.util.FlxColor; import flixel.ui.FlxButton; +import flixel.util.FlxColor; +#if (flixel < version("5.7.0")) +import flixel.ui.FlxButton.HIGHLIGHT; + +typedef FlxButtonState = Int; +#end class Button extends FlxButton { @@ -32,11 +37,11 @@ class Button extends FlxButton /** * Override set_status to change how highlight / normal state looks. */ - override function set_status(Value:Int):Int + override function set_status(Value:FlxButtonState):Int { if (label != null) { - if (Value == FlxButton.HIGHLIGHT) + if (Value == HIGHLIGHT) { #if !mobile // "highlight" doesn't make sense on mobile label.color = FlxColor.WHITE; From c3151747b58ec2823d120127061a824c742c2c1c Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Mon, 18 Mar 2024 10:59:00 -0700 Subject: [PATCH 5/5] Compat 5.7.0 (#334) * use FlxButton * oops fix --- Arcade/MinimalistTD/source/Button.hx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Arcade/MinimalistTD/source/Button.hx b/Arcade/MinimalistTD/source/Button.hx index 09759c6e6..a924e6342 100644 --- a/Arcade/MinimalistTD/source/Button.hx +++ b/Arcade/MinimalistTD/source/Button.hx @@ -4,8 +4,6 @@ import flixel.ui.FlxButton; import flixel.util.FlxColor; #if (flixel < version("5.7.0")) import flixel.ui.FlxButton.HIGHLIGHT; - -typedef FlxButtonState = Int; #end class Button extends FlxButton @@ -37,7 +35,7 @@ class Button extends FlxButton /** * Override set_status to change how highlight / normal state looks. */ - override function set_status(Value:FlxButtonState):Int + override function set_status(Value) { if (label != null) {