Skip to content

Instantly share code, notes, and snippets.

View 01010111's full-sized avatar
πŸ‘½
πŸ•Ή

Will Blanton 01010111

πŸ‘½
πŸ•Ή
View GitHub Profile
@Eiyeron
Eiyeron / CustomSound.hx
Last active January 12, 2025 04:23
Haxe/Heaps custom Sound/Data class pair to generate sound on the fly. Beware, it's experimental and prone to crash if you tweak the wrong knobs.
import hxd.snd.Data;
import hxd.res.Sound;
// This class should work like a Sound. Jsut create one and call play and a lo-fi generated tune should ring.
// You can check out a bit more about bytebeat there : http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
class CustomSound extends Sound {
public function new() {
super(null);
data = new SoundDataGenerator();
}
@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
@thejustinwalsh
thejustinwalsh / DebugInfo.hx
Created April 10, 2019 15:22
Heaps Debug Info UI
class DebugInfo extends h2d.Object
{
var sampleRate:Int;
var fpsText:h2d.Text;
var drawCallText:h2d.Text;
public function new(sampleRate:Int, parent:Null<h2d.Object>)
{
super(parent);
this.sampleRate = sampleRate;
@Jarrio
Jarrio / CArray.hx
Last active February 7, 2020 13:43
Abstract for array allows for backwards referencing indexes, first/last getters and a built in backwards loop!
package utilities;
@:forward abstract CArray<T>(Array<T>) {
public var last(get, never):T;
public var first(get, never):T;
public function new(value) {
this = value;
}
public function rewind(data:T->Void, end:Int = 0) {
@increpare
increpare / Input.hx
Last active October 21, 2020 01:44
dumb joypad\controller support for haxegon
package haxegon;
import lime.ui.GamepadButton;
import starling.events.*;
import openfl.ui.Keyboard;
import openfl.events.FocusEvent;
import lime.ui.Gamepad;
import lime.ui.GamepadButton;
@darmie
darmie / .hxcpp_config.xml
Last active December 18, 2024 19:28
HXCPP Cross Compile to Windows from Mac OSX
<!--
This file will get included twice - once at the beginning - once at the end.
The first time though, the "vars" section is parsed, and this is where you can
set variables to control the setup of the standard compilers and install paths etc.
The second time, the "exes" section is parsed, and you can modify the linkers/compilers
by adding flags to these executables.
-- A note about faking toruses:
-- Spheres under projection become circles.
-- If we treat a torus like a chain of overlapping spheres, then we can draw
-- it using just circfill :)
::_::
cls(1)
-- The camera rotation angle.
q=t()/6
@MSGhero
MSGhero / SmartWordWrap.hx
Last active April 1, 2020 07:29
Layout-aware type text that word wraps without bumping words down
// just contains excerpts and comments
// does not work on Flash. Fine on Windows and HTML5 at least
// involves diving into OpenFL's private API, so no guarantees this will work forever. But it works now!
// probably errors if you start fiddling with the textfield, like setting formats or appendText()
// SmartWordWrap.hx
class SmartWordWrap extends openfl.text.TextField { // gotta extend TextField to have access to internals
var layoutGroups:openfl.Vector<openfl._internal.text.TextLayoutGroup> = new Vector(); // this will cache character information
package fx;
class Dither extends flixel.system.FlxAssets.FlxShader
{
@:glFragmentSource('
#pragma header
const float scale = 2.0;
float checker(vec2 coord)
@xem
xem / JSGameFramework2020.html
Last active November 11, 2023 19:53
JS game framework 2020
<body style=margin:0>
<canvas id=a>
<script>
// initialize 2D canvas (c)
// initialize game state (s)
// initialize keys states (u,r,d,l for directions, k for all the keyboard)
c=a.getContext`2d`,k=[u=r=d=l=s=0]
// (initialize your global variables here)