1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <iostream>
using namespace std;
// example map
int map[3][5] = {
1, 1, 1, 1, 1,
0, 1, 1, 0, 1,
0, 1, 1, 0, 1
};
// function declarations
void doMap();
int main()
{
doMap();
return 0;
}
void doMap()
{
int tileId;
int tilex = 0, tiley = 0; // screen position start
// assuming your tiles are 64 x 64 pixels
for (int down = 0; down < 3; down++)
{
for (int across = 0; across < 5; across++)
{
// we now have down and across, so...
tileId = map[down][across];
// draw tile of tileId at tilex, tiley
tilex += 64; // move screen pos over for next tile
}
tiley += 64; // move screen pos down for next tile.
tilex = 0; // reset x
}
}
|