So I have my SDL project to read tiles from a tile sheet via a .txt file. I have a separate tile sheet that consists of random 32 x 32 characters. My level gets drawn out something like so...
22 16
0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0
0 0 1 1 0 1 1 0 0 0
etc... you get the idea...
However placing NPC's would like work the same. So how would I read in an NPC's location via a txt file. so that it goes something as follows..
0 32 32
1 32 128
0 being NPC 0 and 1 being NPC 1 followed by the coords I want them to draw to. I have some rects set up for both the tiles and some of the NPC's. They are as follows:
tile[WATER].x = 64;
tile[WATER].y = 0;
tile[WATER].w = 32;
tile[WATER].h = 32;
players[ORK].x = 0;
players[ORK].y = 64;
players[ORK].w = 32;
players[ORK].h = 32;
so this would seperate the water tile from the tile sheet, so when you call it, its only the water, and same for the Ork character.
So with this set up, how would I draw diff characters to the screen via a txt file formate?
My current source:
http://pastebin.com/m1e7e344f
My guess is that I have to change the way you read in the file. Which would be this bit. But I am not sure entirely.
player_file >> playerWidth >> playerHeight;
for (int y = 0; y < playerHeight; ++y) {
for (int x = 0; x < playerWidth; ++x) {
player_file >> playerData[x][y];
}
}