[common] bullet with bricks collision

This commit is contained in:
2018-01-07 20:33:05 +03:00
parent 12328a8a5e
commit 348d31d754
33 changed files with 277 additions and 217 deletions

View File

@@ -0,0 +1,49 @@
package ru.m;
import haxe.io.Bytes;
import haxe.crypto.BaseCode;
class Base64 {
private inline static var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
private static var codec:BaseCode;
public function new() {
}
static function getCodec():BaseCode {
if (codec == null) {
var bytes = Bytes.ofString(BASE64);
codec = new BaseCode(bytes);
}
return codec;
}
public static function encodeBase64(content:haxe.io.Bytes):String {
var suffix = switch (content.length % 3){
case 2: "=";
case 1: "==";
default: "";
};
var bytes = getCodec().encodeBytes(content);
return bytes.toString() + suffix;
}
private static function removeNullbits(s:String):String {
var len = s.length;
while (len > 0 && s.charAt(len - 1) == "=") {
len--;
if (len <= 0) {
return "";
}
}
return s.substr(0, len);
}
public static function decodeBase64(content:String):Bytes {
var bytes:Bytes = Bytes.ofString(removeNullbits(content));
return getCodec().decodeBytes(bytes);
}
}