How do I draw my map

Hi every one it’s Cody I was wondering how do I draw this map

and yes I’ve tried reading the magazines they didn’t help I just want to display the map

That’s a bit unclear but I’ll have a go.

static const uint8_t MapWidth = 12; // I think I counted 12
static const uint8_t MapHeight = 6;

static const uint8_t TileWidth = 8;
static const uint8_t TileHeight = 8;

uint8_t getMapTile(uint8_t x, uint8_t y)
  // This calculation comes from what's called a 'flat array'
  // which is a way of using 2-dimension indexing on a 1-dimension array
  return pgm_read_byte(&mapArrray[x + (MapWidth * y)]);

void loop()
  if(!arduboy.nextFrame()) return;


  for(uint8_t y = 0; y < MapHeight; ++y)
    for(uint8_t x = 0; x < MapWidth; ++x)
      Sprites::drawOverwrite(x * TileWidth, y * TileHeight, tileSheet, getMapTile(x, y));


Disclaimer: untested.
Post the chunk in the photo and I’ll test/tweak it.


Comes up with this error

Me thinks it’s a error on you side mabey and yes I changed the map tiles to a 3x3

You forgot a semicolon…
And added one where there shouldn’t be one…


Thanks man! Got it all working! Here’s a pic of the edited map!
Now that’s one problem down 2 to go! :wink:

1 Like