Skip to content

Instantly share code, notes, and snippets.

package states;
import flixel.util.FlxColor;
import flixel.FlxG;
import flixel.FlxSprite;
class DoNothingShaderTestState extends flixel.FlxState
{
override function create()
{
@AustinEast
AustinEast / Listener.hx
Last active April 21, 2021 19:02
Simple collision listener implementation for Haxeflixel. Grabbed from the source code of Wet Jet Racing!
package;
typedef Listener =
{
tag1:String,
tag2:String,
callback:Dynamic->Dynamic->Void
}
@Yanrishatum
Yanrishatum / hxsl-cheatsheet.md
Last active March 28, 2025 05:31
HXSL cheat-sheet

HXSL cheat-sheet

This is a WIP of a cheat-sheet that I will finish Eventually™

Types

Mapping of the shader types to Heaps types:

Float = Float
Int = Int
Bool = Bool
@AustinEast
AustinEast / Outline.hx
Last active January 2, 2023 09:41
HaxeFlixel Pixel-Perfect Outline Shader
import flixel.system.FlxAssets.FlxShader;
import flixel.util.FlxColor;
class Outline extends FlxShader
{
@:glFragmentSource('
#pragma header
uniform vec2 size;
uniform vec4 color;
@01010111
01010111 / FlxEcho.hx
Last active April 29, 2021 17:25
Quick Flixel <-> Echo integration
package util;
import echo.data.Options.BodyOptions;
import flixel.FlxBasic;
import flixel.FlxObject;
import flixel.FlxObject.*;
import flixel.group.FlxGroup;
import echo.Echo;
import echo.World;
import echo.Body;
@Yanrishatum
Yanrishatum / heapsfaq.md
Last active November 29, 2024 04:19
An Unofficial Heaps FAQ

An Unofficial Heaps FAQ

I (Yanrishatum) see too many same questions. They irritate me.

Translation

"How dare you come into this chat and not realize that i am the GOD of heaps and that you MUST check out MY documentation1!!! Im veyr abngrey!!!" - translation from someone in chat.

Very accurate, I highly approve.

@ruccho
ruccho / Generate Normal Map for all frames.lua
Last active April 25, 2025 17:08
Lua script for Aseprite that generates normal map automatically from all frames of selected layers.
----------------------------------------------------------------------
-- Generate Normal Map
--
-- It works only for RGB color mode.
----------------------------------------------------------------------
if app.apiVersion < 1 then
return app.alert("This script requires Aseprite v1.2.10-beta3")
end
@MSGhero
MSGhero / flixel-big-issues.md
Last active October 24, 2020 06:14
A list of issues in Flixel everyone keeps complaining about, so that we actually propose fixes

FlxSpriteGroup

  • FlxSpriteGroup shouldn't exist, but Flixel's "easy to get into" mindset means it has to exist. So now, the class is halfway between AS3 (sprite grouping is the default) and Kha (sprite grouping is DIY)
  • Issues: setting alpha to 0 is unrecoverable. MouseChildren handling subpar, especially compared to flash.display.Sprite#mouseChildren
  • Potential solution: give FlxBasic/Object/Sprites a parent:FlxTypedGroup<> property and propagate that change throughout the lib
  • Impact to lib: major
  • Effort required: possibly a lot
  • Breaking: mouseChildren behavior could be changed to match AS3's

Inheritance

  • Flixel greatly relies on inheritance, which makes it difficult to use
@AustinEast
AustinEast / haxeflixel-pixel-perfect.md
Last active May 6, 2024 15:07
Pixel perfect rendering with HaxeFlixel on desktop targets

To get Haxeflixel to maintain 1:1 pixel rendering at any scale for desktop targets:

In your Project.xml, add a new window property with an desktop conditional, resizable set to false, and the desired width/height to match the resolution you'd like to maintain.

<window if="desktop" resizable="false" width="320" height="180" />

Apply a shader to the FlxGame instance or the main FlxCamera instance as a filter. The base FlxShader can even just be used if the project doesn't require custom shaders.

FlxG.game.setFilters([new ShaderFilter(new FlxShader())]);
@xem
xem / readme.md
Last active April 18, 2025 20:19
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;