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
#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1] | |
#define CHECK_SIZE(a) (sizeof(a)/sizeof(a[0])) | |
#define NUM_DIR 4 | |
#define NUM_BUT 6 | |
#define NUM_INPUT (NUM_DIR + NUM_BUT) | |
#define LEFT 0 | |
#define RIGHT 1 | |
#define UP 2 |
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 com.grapefrukt.games.slicer.utils; | |
/** | |
* ... | |
* @author Martin Jonasson, [email protected] | |
*/ | |
class ConvexHull { | |
public static function get<T:{x:Float, y:Float}>(vertices:Array<T>):Array<T> { |
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
static function setconfig(target:Dynamic, config:Dynamic) { | |
// iterate over the fields of the config object | |
for (key in Reflect.fields(config)) { | |
// make sure our target has this field | |
if (!Reflect.hasField(target, key)) continue; | |
// fetch the value of the first field | |
var configvalue:Dynamic = Reflect.field(config, key); | |
// check if its and object, and if so, make sure it actually has multiple values inside | |
// (strings are for some reason considered objects) |
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 flash.text; | |
import openfl.text.TextField; | |
import openfl.text.TextFormat; | |
/** | |
* ... | |
* @author Martin Jonasson, [email protected] | |
*/ | |
#if flash | |
typedef RTextField = TextField; |
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
class Main { | |
// this particular setup gives me the error: | |
// Main.hx:12: characters 22-85 : Variable initialization must be a constant value | |
// set either GRID_SIZE, CELL_SIZE or OUTLINE_RATIO to anything else and it's fine | |
public static inline var GRID_SIZE :Int = 20; | |
public static inline var CELL_SIZE :Int = GRID_SIZE - 2; | |
public static inline var OUTLINE_RATIO :Float = 1.2; |
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
/* | |
The MIT License | |
Copyright (c) <year> <copyright holders> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
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 flash.text; | |
import flash.display.BitmapData; | |
import flash.display.Sprite; | |
/** | |
* Wraps a regular TextField and renders it to a Bitmap without it ever being on the DisplayList. | |
* Used to work around this bug: https://github.com/openfl/lime/issues/20 | |
* @author Martin Jonasson, [email protected] | |
*/ | |
class RTextField extends Sprite { |
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 flash.display.Sprite; | |
import flash.events.Event; | |
import flash.Lib; | |
import flash.text.TextField; | |
class Main extends Sprite { | |
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 com.grapefrukt.utils; | |
/** | |
* Retrieves the version of Windows the application is running under | |
* @author Martin Jonasson, [email protected] | |
*/ | |
class WindowsVersion { | |
private static var inited:Bool = false; | |
private static var _major:Int = 0; |
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 flash.errors.Error; | |
import flash.net.SharedObject; | |
/** | |
* Completely unnecessary wrapper for SharedObject | |
* @author Martin Jonasson, [email protected] | |
*/ | |
class SaveData { |