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
window.addEventListener("resize", ()=>{ | |
const scaleX = window.innerWidth / app.screen.width; | |
const scaleY = window.innerHeight / app.screen.height; | |
const scale = Math.min(scaleX, scaleY); | |
const gameWidth = Math.round(app.screen.width * scale); | |
const gameHeight = Math.round(app.screen.height * scale); | |
const marginHorizontal = Math.floor((window.innerWidth - gameWidth) / 2); | |
const marginVertical = Math.floor((window.innerHeight - gameHeight) / 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
/** | |
* Binary class for haxe. | |
* To make bit masking a bit easier on the eye. | |
*/ | |
@:forward | |
abstract Binary(Int) from Int to Int | |
{ | |
inline public function new(i:Int) | |
{ | |
this = i; |
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
//This is not a real .hx class file. Drop this into a class you see fit. | |
//Feed it a bitmap data and save it to PNG. | |
public static function saveImage(bitmapData:BitmapData) | |
{ | |
var b:ByteArray = new ByteArray(); | |
b = bitmapData.encode(bitmapData.rect, new PNGEncoderOptions(true), b); | |
new FileDialog().save(b, "png", null, "file"); | |
} |
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.Json; | |
/** | |
* Toss a Dynamic var and get a typedef declaration! (Inspired by http://json2csharp.com) | |
* (A bit of code stolen from https://gist.github.com/elsassph/16d3b2597f6a51b5817c2fa97dd7f505) | |
* @author Milton Candelero (Elemental Code) | |
*/ | |
class JsonClass | |
{ |