Skip to content

Instantly share code, notes, and snippets.

View AxGord's full-sized avatar
🦄
Pony

Alexander Gordeyko AxGord

🦄
Pony
View GitHub Profile
import pony.time.Tween;
class TweenExample {
static function main() {
var obj = new Sprite();
new Tween(20...100, '3s').onUpdate << function(v:Float) obj.y = v;
}
}
@AxGord
AxGord / ParentClass.hx
Created February 24, 2016 11:10
Asset managet example
/**
* ParentClass
* @author AxGord <[email protected]>
*/
@:assets_path('assets')
class ParentClass implements HasAsset {
@:asset public static var MY_ASSET = 'myasset3.png';
static function main() {
@AxGord
AxGord / GenericBuildMacro.hx
Created June 9, 2018 15:35
Generic macro abstract function!
import haxe.macro.TypeTools;
import haxe.macro.Expr;
import haxe.macro.Context;
import haxe.macro.Type;
class GenericBuildMacro {
static public function build():ComplexType {
var w = Config.width;
var h = Config.height;
var space:NapeSpaceView = new NapeSpaceView(new Point<Float>(0, 600));
space.debugLines = {size: 3, color: 0xFFFFFF};
c.addChild(space);
space.createStaticRect(new Rect<Float>(50, h - 50, w - 100, 1));
space.createStaticRect(new Rect<Float>(w - 50, 50, 1, h - 100));
class Test {
static function main() {
var a = new Priority();
a.add(3, 2);
a.add(1, 1);
trace(a.a);
}
}
class Test {
static function main() {
var a = new SmartArray([1, 2, 3]);
for (e in a) {
trace(e);
if (e == 2) a.remove(1);
}
}
}
import pony.net.SocketClient;
import pony.net.SocketServer;
import pony.time.MainLoop;
class NekoSockets {
private static function main():Void {
MainLoop.init();
var port = 12345;
import pony.net.*;
import pony.net.rpc.*;
import pony.events.*;
import pony.time.MainLoop;
class RPCExample {
private static function main():Void {
MainLoop.init();
import haxe.Constraints.Function;
/*
Result:
src/Main.hx:16: Function bench
src/Main.hx:76: 0.019 sec
src/Main.hx:19: Signal bench
src/Main.hx:76: 0.01 sec
*/
@AxGord
AxGord / UInt.hx
Last active December 11, 2019 19:31
class Main {
private static function main():Void {
trace(-1 > (5: UInt));
}
}
abstract UInt(Int) from Int to Int {
@:op(A + B) private static inline function add(a:UInt, b:UInt):UInt {