Skip to content

Instantly share code, notes, and snippets.

@Orpheon
Created March 26, 2014 21:29
Show Gist options
  • Select an option

  • Save Orpheon/9794030 to your computer and use it in GitHub Desktop.

Select an option

Save Orpheon/9794030 to your computer and use it in GitHub Desktop.
// Make the actual 2d array
map->mask = (bool**) calloc(map->width, sizeof(bool*));
for (int i=0; i<map->width; i++)
{
map->mask[i] = (bool*) calloc(map->height, sizeof(bool));
}
// Data is stored in the first 6 bits of every byte, and apparently bottom-right to top-left
int bitmask = 0x1;
char* index = end_position - 1;
int value = ((int) index[0]) - 32;
// Since it's unlikely that the size of the map is mod 6 == 0, first take out the starting bits from the first byte
for (int i=0; i<(end_position-start_position)*6 - ((map->width/6)*(map->height/6)); i++)
{
bitmask *= 2;
}
for (int j=map->height-6; j>=0; j-=6)
{
for (int i=map->width-6; i>=0; i-=6)
{
if (bitmask == 64)
{
// Next/Previous character
index--;
value = ((int) index[0]) - 32;
bitmask = 0x1;
}
if (value & bitmask)
{
// This part is solid
for (int k=0; k<6; k++)
{
for (int l=0; l<6; l++)
{
map->mask[i+k][j+l] = true;
}
}
}
bitmask *= 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment