Skip to content

Instantly share code, notes, and snippets.

@ibilon
ibilon / Main.hx
Created July 4, 2013 10:54
RAM used by the flashplayer.
import flash.events.Event;
import flash.display.Sprite;
import flash.system.System;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.Lib;
class Main
{
/**
@ibilon
ibilon / Main.hx
Created August 23, 2013 15:32
HaxePunk test keyboard input
import com.haxepunk.Engine;
import com.haxepunk.utils.Input;
import com.haxepunk.utils.Key;
import flash.events.KeyboardEvent;
import flash.Lib;
class Main extends Engine
{
override public function init()
@ibilon
ibilon / Inputs.hx
Last active December 22, 2015 05:49
Haxepunk fusion of input and joystick check/pressed.
import com.haxepunk.utils.Input;
import com.haxepunk.utils.Joystick;
class Inputs
{
static function define_input (name:String, keys:Array<Int>)
{
Input.define(name, keys);
}
import com.haxepunk.HXP;
import com.haxepunk.Entity;
import com.haxepunk.graphics.Text;
import com.haxepunk.graphics.Image;
import com.haxepunk.utils.Input;
class Paper extends Entity
{
var stringIterator:Int;
var showText:Text;
class Entity extends com.haxepunk.Entity
{
public var worldCollider : IEntityBehavior;
public var moveHandler : IEntityBehavior;
override public function update ()
{
worldCollider.update();
moveHandler.update();
@ibilon
ibilon / API.md
Last active August 29, 2015 14:02
Proposed API for HaxePunk 3.0
  • haxepunk
    • graphics
      • Graphic
      • Image
      • Text
      • AnimatedSprite
      • TileMap
      • Mesh
      • Light
  • ParticleEmitter
@ibilon
ibilon / Main.hx
Last active August 29, 2015 14:02
Resource management
class Main extends Engine
{
override function init()
{
// resources added in Engine are kept in memory
resources.addTexture("graphics/player.png");
// if a Scene resources aren't all available push preloader on scene stack until they are
preloader = new MyCustomPreloadingScreen();
@ibilon
ibilon / Main.hx
Last active August 29, 2015 14:26
HaxePunk maintain ratio
import com.haxepunk.Engine;
import com.haxepunk.HXP;
import com.haxepunk.utils.Draw;
class Main extends Engine
{
override public function init()
{
#if debug
@ibilon
ibilon / Test.hx
Last active September 22, 2015 17:04
Array Multi Type
class Test {
static function main() {
var ar = new MyArray<Int>([1, 2, 5]);
trace(ar);
ar.length = 5;
trace(ar);
ar.length = 2;
trace(ar);
var ar2 = new MyArray<Float>([1.1, 2.2, 5.5]);
@ibilon
ibilon / Test.hx
Created November 17, 2015 14:47
Compile time macro define information
class Test {
static function main() {
trace(isDemo());
}
macro static function isDemo () : haxe.macro.Expr
{
return macro $v{haxe.macro.Compiler.getDefine("demo") != null};
}
}