Skip to content

Instantly share code, notes, and snippets.

@zicklag
zicklag / CharacterController2.hx
Last active May 21, 2020 05:48
A WIP Armory3D Character Controller
package arm;
import kha.graphics4.hxsl.Types.Vec;
import kha.FastFloat;
import iron.math.Quat;
import iron.math.Vec4;
import haxe.Log;
import armory.trait.physics.PhysicsWorld;
import iron.system.Input;
import armory.trait.physics.bullet.RigidBody;
@nadako
nadako / 1 Main.hx
Last active October 16, 2021 04:38
ocaml-like `with` for Haxe
using WithMacro;
typedef Player = {
final name:String;
final level:Int;
}
class Main {
static function main() {
var player = {name: "Dan", level: 15};
@markknol
markknol / haxe.json
Last active January 28, 2020 18:31
vscode haxe snippets
{
/*
// Place your snippets for Haxe here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// \t, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
@Simn
Simn / Main.hx
Created March 22, 2016 20:52
Simple assert macro that shows sub-expressions
class Main {
static function main() {
var x = 7;
var y = 10;
tools.Assert.assert(x == 7 && y == 11);
}
}
@hamaluik
hamaluik / !Profiler.hx
Last active April 6, 2020 23:11
Simple Haxe Profiler
package ;
import haxe.ds.StringMap;
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Printer;
import haxe.macro.Type.ClassType;
import neko.Lib;
using haxe.macro.ExprTools;
@nadako
nadako / Main.hx
Last active February 19, 2019 02:07
Tuple builder using new Rest feature of @:genericBuild
class Main {
static function main() {
var a = getValue();
}
static function getValue():Tuple<Bool,Int> {
return new Tuple(true, 10);
}
}
@Simn
Simn / Fast.hx
Created March 14, 2014 09:25
Haxe abstract + macro Xml fun
import haxe.macro.Expr;
using haxe.macro.Tools;
abstract Fast(Xml) from Xml to Xml {
@:noCompletion public inline function new(xml:Xml) this = xml;
public var name(get,never):String;
inline function get_name() return this.nodeName;
public var elements(get,never):FastIterator;
@nadako
nadako / 1 Main.hx
Created February 18, 2014 22:19
Using haxe macros as syntax-tolerant, position-aware json parser
import haxe.macro.Context;
import haxe.macro.Expr;
using haxe.macro.ExprTools;
class Main
{
inline static var QUOTED_FIELD_PREFIX = "@$__hx__";
static function main()
import haxe.macro.Expr;
class FTW
{
public static function build()
{
return haxe.macro.Context.getBuildFields().map(transformField);
}
static function transformField(field:Field)
@jdonaldson
jdonaldson / hxn.sh
Last active December 15, 2015 11:49
Simple bash script for switching between haxe nightly and stable
export OLDPATH=$PATH
export HAXE_NIGHTLY=$HOME/bin/haxe_nightly
hxn(){
if [ -z "$USE_HAXE_NIGHTLY" ] || $USE_HAXE_NIGHTLY; then
echo "Changing to Haxe stable version"
export HAXE_STD_PATH=$OLD_HAXE_STD
export PATH=$OLDPATH
export USE_HAXE_NIGHTLY=false
else
echo "Changing to Haxe nightly at: $HAXE_NIGHTLY"