First game and the tilemap

I started to code my first game yesterday on arduboy. I wan’t to make a simple jump&run first. So I read a bit about tiles etc. Then i created a simple tile and player bitmap. Now i want to store the map in an tile map. Isn’t it possible to store the map in just a simple char array? Because when i draw the tiles from such an array nothing happens. In the following code it should at least draw the tiles in the first row…

const unsigned char tile1[] PROGMEM  = {
    0xff, 0xff, 0x33, 0x33, 0x3, 0x3, 0xf, 0xf, 0xc3, 0xc3, 0x3, 0x3, 0xcf, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xc0, 0xf3, 0xf3, 0xc0, 0xc0, 0xcc, 0xcc, 0xc0, 0xc0, 0xcc, 0xcc, 0xff, 0xff,  
const unsigned char maparray[] PROGMEM = {

int bgcounterX = 1;
int bgcounterY = 1;

void setup() {
  for(char x = 0; x<=24; x++)
    if(maparray[x] == 1)
    bgcounterX = bgcounterX +16;

After that i would increase the bgcounterY to draw the next line. Where is my problem?

You’ve put maparray[] in PROGMEM, so you can’t just directly reference it. You need to use something like:

if (pgm_read_byte(maparray + x) == 1)
1 Like

Wow i never thought about the storage. Thanks for the help and the link! I see that there is much more to keep in mind when programming for such a board :blush: Can anyone maybe recommend a book for the basics of game programming in such a ‘low level’ way and without an engine?