Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Pony

Alexander Gordeyko AxGord

🦄
Pony
View GitHub Profile
View UInt.hx
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 {
View SignalBenchmark.hx
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
*/
View RPCExample.hx
import pony.net.*;
import pony.net.rpc.*;
import pony.events.*;
import pony.time.MainLoop;
class RPCExample {
private static function main():Void {
MainLoop.init();
View NekoSockets.hx
import pony.net.SocketClient;
import pony.net.SocketServer;
import pony.time.MainLoop;
class NekoSockets {
private static function main():Void {
MainLoop.init();
var port = 12345;
View ArrayWithSafeRemove.hx
class Test {
static function main() {
var a = new SmartArray([1, 2, 3]);
for (e in a) {
trace(e);
if (e == 2) a.remove(1);
}
}
}
View Priority.hx
class Test {
static function main() {
var a = new Priority();
a.add(3, 2);
a.add(1, 1);
trace(a.a);
}
}
View pony_nape_brick_wall_destruct_demo.hx
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));
@AxGord
AxGord / GenericBuildMacro.hx
Created Jun 9, 2018
Generic macro abstract function!
View GenericBuildMacro.hx
import haxe.macro.TypeTools;
import haxe.macro.Expr;
import haxe.macro.Context;
import haxe.macro.Type;
class GenericBuildMacro {
static public function build():ComplexType {
@AxGord
AxGord / ParentClass.hx
Created Feb 24, 2016
Asset managet example
View ParentClass.hx
/**
* ParentClass
* @author AxGord <axgord@gmail.com>
*/
@:assets_path('assets')
class ParentClass implements HasAsset {
@:asset public static var MY_ASSET = 'myasset3.png';
static function main() {
View TweenExample.hx
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;
}
}
You can’t perform that action at this time.