Skip to content

Instantly share code, notes, and snippets.

View anissen's full-sized avatar

Anders Nissen anissen

View GitHub Profile
@anissen
anissen / Main.hx
Last active July 6, 2016 08:46 — forked from elsassph/ResourceGenerator.hx
Haxe build macro converting a JSON file into strongly typed, inline/dce friendly, properties
class Main {
public static function main() {
trace(R.list);
trace(R.obj.foo);
}
}
@anissen
anissen / Perlin.hx
Last active April 12, 2016 13:33
Animated perlin noise example
class Perlin {
public var repeat :Int;
public function new(repeat :Int = -1) {
this.repeat = repeat;
}
public function OctavePerlin(x :Float, y :Float, z :Float, octaves :Int, persistence :Float) {
var total :Float = 0;
var frequency :Float = 1;
@anissen
anissen / Test.hx
Created March 7, 2016 20:44
Diamond-square algorithm for generating realistic terrain
class Heightmap {
var size :Int;
var tiles :Array<Array<Null<Float>>>;
var d :Int;
public function new() {
}
@anissen
anissen / Main.hx
Last active March 26, 2016 16:53
Luxe kitchen sink test
import luxe.Component;
import luxe.Input;
import luxe.Parcel;
import luxe.ParcelProgress;
import luxe.Rectangle;
import luxe.Sprite;
import luxe.Color;
import luxe.tween.easing.*;
import luxe.Text;
@anissen
anissen / GeneratorParser.hx
Last active March 24, 2016 20:14
Parser for simple generative grammar
enum Token {
TSymbol(s :String);
TTerminal(s :String);
TArrow;
TPlus;
TBracketOpen;
TBracketClose;
TNumber(v :Float);
TEof;
@anissen
anissen / GenNew.hx
Last active February 23, 2016 12:14 — forked from ibilon/GenNew.hx
Object construction with macro
import haxe.macro.Expr;
import haxe.macro.Context;
class GenNew {
macro public static function build () : Array<Field> {
var fields = Context.getBuildFields();
var args = [];
var assigns = [];
for (field in fields) {
@anissen
anissen / Test.hx
Created January 29, 2016 17:00
Generative grammar for procedural quest generation
// Inspired by
// http://www.jorisdormans.nl/pdf/dormans2010_AdventuresInLevelDesign.pdf
// http://larc.unt.edu/ian/pubs/pcg2011.pdf
// http://larc.unt.edu/ian/pubs/DoranParberryQuests2015.pdf
// Idea: Use a macro to extract Symbol and Terminal information and populate enums
enum Symbol {
Quest;
SubQuest;
@anissen
anissen / Test.hx
Last active January 24, 2016 20:59
Generative grammar for procedural generation
// Inspired by http://www.jorisdormans.nl/pdf/dormans2010_AdventuresInLevelDesign.pdf
enum Symbol {
Dungeon;
Obstacle;
}
enum Terminal {
Treasure;
Key;
@anissen
anissen / Test.hx
Created January 7, 2016 21:41
hscript revised test
class Script {
var program :hscript.Expr;
var interp :hscript.Interp;
public function new(source :haxe.io.Input) {
var parser = new hscript.Parser();
interp = new hscript.Interp();
try {
program = parser.parse(source);
@anissen
anissen / gist:7535140
Created November 18, 2013 20:56
Temp. fork of Fractal Cartoon on ShaderToy
// "Fractal Cartoon" - former "DE edge detection" by Kali
// Cartoon-like effect using eiffies's edge detection found here:
// https://www.shadertoy.com/view/4ss3WB
// I used my own method previously but was too complicated and not compiling everywhere.
// Thanks to the suggestion by WouterVanNifterick.
// There are no lights and no AO, only color by normals and dark edges.