port and upgrade of precalc in haxe/haxeflixel