Skip to content

Instantly share code, notes, and snippets.

View AustinEast's full-sized avatar
🍞

Austin East AustinEast

🍞
View GitHub Profile
@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
}
@AustinEast
AustinEast / Macros.hx
Created April 13, 2021 15:25
Haxe Macro for defining simple data Classes from an Array of Strings
import haxe.macro.Context;
using StringTools;
class Macros {
static final node_package = 'nodes';
static final node_prefix = 'Node';
static function title_case(str:String) {
return str.length < 1 ? str.toUpperCase() : str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();
@AustinEast
AustinEast / ClassID.hx
Last active December 19, 2020 02:18
Haxe Macro for defining unique IDs per Class
#if macro
import haxe.macro.Type;
import haxe.macro.Context;
import haxe.macro.Expr;
#end
/**
* Implementing this interface on a Class will run `ClassID.build()`, then remove itself.
**/
@:remove
@AustinEast
AustinEast / .FlxEcho.md
Last active March 19, 2021 19:58 — forked from 01010111/FlxEcho.hx
Quick Flixel <-> Echo integration

2021 Update - The code in this Gist has been compiled into a haxelib for a more convenient experience! Please upgrade as this Gist will no longer be updated! Check out the repo here: https://github.com/AustinEast/echo-flixel

Quick and easy integration of Echo Physics with Haxeflixel! To get started follow these steps:

  1. Copy the content from 01-Project.xml to your own Project.xml.
  2. Create a new directory named util in the root of source code directory.
  3. Create a new file named FlxEcho.hx in the util directory.
  4. Copy the content from 02-FlxEcho.hx into the FlxEcho.hx file.

After that, you're ready to go! Check out 03-PlayState.hx to see a simple example of how to use FlxEcho.

@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;
@AustinEast
AustinEast / ParticleEmitter.hx
Last active August 28, 2020 10:17
re-implementation of zerolib's ParticleEmitter.hx for HaxeFlixel, without zerolib
package;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.math.FlxPoint;
/**
* A particle emitter class.
*
* Originally written for zerolib by @01010111
@AustinEast
AustinEast / Store.hx
Last active February 21, 2020 22:58
Simple Store Abstract For Haxe
using Math;
/**
* A Simple Store of Data that is accessible through Queries. It is Abstracted over the Array type, so casting between the two is supported.
*/
abstract Store<T>(Array<T>) from Array<T> to Array<T> {
public inline function new(?v:Array<T>) this = v == null ? [] : v;
/**
* Gets the first item that matches the Query.
*/
@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())]);