This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import luxe.Component; | |
import luxe.Rectangle; | |
import luxe.Vector; | |
// import luxe.Sprite; | |
import phoenix.Texture; | |
import luxe.Log.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
#if macro | |
import haxe.Json; | |
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.Type; | |
import sys.io.File; | |
import sys.FileSystem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import luxe.Input; | |
typedef AccelEvent = { | |
timestamp:Float, | |
value:Float, | |
axis:Int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@:structInit | |
class A { | |
var x:Int; | |
var y:Int; | |
} | |
@:structInit | |
class B { | |
var a:A; | |
var k:Int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import js.Browser.*; | |
import js.html.CanvasElement; | |
import js.html.CanvasRenderingContext2D; | |
import js.html.HTMLDocument; | |
import js.html.MouseEvent; | |
import sf.test.Test.Entity; | |
/** | |
* @author YellowAfterlife | |
* http://yal.cc/top-down-bouncing-loot-effects/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.ComplexTypeTools; | |
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.ExprTools; | |
import haxe.macro.Type.TInst; | |
import haxe.macro.TypeTools; | |
class ClassBuild{ | |
//the entire contents of a class is contained in the class's fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override function onwindowsized( e:WindowEvent ):Void { | |
zoomRatio.x = Math.floor(Luxe.screen.w / gameResolution.x); | |
zoomRatio.y = Math.floor(Luxe.screen.h / gameResolution.y); | |
//get the smallest zoom ratio between zoomRatio.x and zoomRatio.y, and limit it to be greater or equal 1 | |
zoom = Math.floor(Math.max(1, Math.min(zoomRatio.x, zoomRatio.y))); | |
var width = gameResolution.x * zoom; | |
var height = gameResolution.y * zoom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Mark Knol | |
*/ | |
class MacroJsonValidator { | |
public static macro function validateJson(path:String) { | |
if (sys.FileSystem.exists(path)) { | |
var content = sys.io.File.getContent(path); | |
try { | |
// Test the json by parsing it. | |
// It will throw an error when you made a mistake. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.ds.Either; | |
abstract OneOf<A, B>(Either<A, B>) from Either<A, B> to Either<A, B> { | |
@:from inline static function fromA<A, B>(a:A) : OneOf<A, B> return Left(a); | |
@:from inline static function fromB<A, B>(b:B) : OneOf<A, B> return Right(b); | |
@:to inline function toA():Null<A> return switch(this) {case Left(a): a; default: null;} | |
@:to inline function toB():Null<B> return switch(this) {case Right(b): b; default: null;} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if macro | |
import haxe.macro.Context; | |
#end | |
class Main { | |
macro static function load_json(file :String) { | |
var data = sys.io.File.getContent(file); | |
var json = haxe.Json.parse(data); | |
return Context.makeExpr(json, Context.currentPos()); |