it’s a fun puzzle to solve. ill give you a hint: it involves modular division. the easiest way to approach it is to put the entire tileset into a level for testing/looking
here. i found some code i wrote a while back. it’s a python level object.
class Level(object):
"""Load and store the map of the level, together with all the items."""
def get_number(self, char):
c = ord(char)
if c >= ord('A') and c <= ord('Z'): return c - ord('A')
if c >= ord('a') and c <= ord('z'): return c - ord('a') + 26
if c >= ord('0') and c <= ord('9'): return c - ord('0') + 52
if c == ord('+'): return 62
if c == ord('/'): return 63
return 0xFF
def __init__(self, filename="new4.nw"):
self.tileset = ''
self.map = []
self.items = {}
self.key = {}
self.width = 0
self.height = 0
self.load_file(filename)
def load_file(self, filename="new4.nw"):
"""Load the level from specified file."""
graallevel = open(filename)
graallevel.readline()
self.tileset = "pics1.png"
for line in graallevel:
self.map.append(line.rstrip('\
').split(" ")[5])
for line in self.map:
keys = [line[i:i+2] for i in range(0, len(line), 2)]
for key in keys:
"""Here is where I can define blocking tiles wooooo"""
tileinfo = {}
tileinfo["blocking"] = "false"
tileinfo["tile"] = str(self.get_number(key[1])%16 + int((self.get_number(key[0])/8)*16))+", "+str((self.get_number(key[0])%8)*4 + int(self.get_number(key[1])/16))
tileinfo["blocking"] = "false"
self.key[key] = tileinfo
self.width = len(self.map[0])/2
self.height = len(self.map)
Here’s how I solve it.
This is a snippet of java from one of my projects.
public static final String BASE_64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
public static int Base64ToIndex(String base64)
{
int baseMul = BASE_64.indexOf(base64.charAt(0));
int base = BASE_64.indexOf(base64.charAt(1));
return baseMul * BASE_64.length() + base;
}
public static String IndexToBase64(int index)
{
int baseMul = Math.floorDiv(index, BASE_64.length());
int base = index - baseMul * BASE_64.length();
return Character.toString(BASE_64.charAt(baseMul)) + Character.toString(BASE_64.charAt(base));
}
public static final String BASE_64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
public static int Base64ToIndex(String base64)
{
int baseMul = BASE_64.indexOf(base64.charAt(0));
int base = BASE_64.indexOf(base64.charAt(1));
return baseMul * BASE_64.length() + base;
}
public static String IndexToBase64(int index)
{
int baseMul = Math.floorDiv(index, BASE_64.length());
int base = index - baseMul * BASE_64.length();
return Character.toString(BASE_64.charAt(baseMul)) + Character.toString(BASE_64.charAt(base));
}