Tiling in SDL

I'm in the beginning stages of designing my first video game using SDL, and have run into a bit of an impasse. I attempt to draw the map using a simple tile function and nothing prints to the screen. I am going to attach the function itself, but if you are willing to help and need more information feel free to ask and I will provide.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
bool Tile::draw_tiles ( void ) {
	GV gv;

	//Open the map
	std::ifstream map ( "test.map" );
	for ( int y = 0; y < GV::MAP_HEIGHT / 64; y++ ) {
		for ( int x = 0; x < GV::MAP_WIDTH / 64; x++ ) {
			int tile_type = -1;

			map >> tile_type;
	
			if ( map.fail() || tile_type < 0 || tile_type >= GV::TILE_COUNT ) {
				map.close();
				return false;
			}

			gv.apply_surface ( x * 64, y * 64, gv.SDLS_tiles, gv.SDLS_screen, &tile_index[tile_type].crop );
		}
	}
	map.close();
	return true;
}


Extra notes:
1. Compiles fine.
2. No run time errors (this function returns true).
3. Apply surface is a function that takes an x and y value for position on the
map, an image, a screen to print it to, and a rectangle to cut out the image out of.
4. I did some bug testing and added another function to print the image SDLS_tiles by itself (its just a simple sprite map) after the map.close() function, and it worked fine.

I realize that you might need some more information, such as the code to my tile_index structure. Just ask for it and I will add it, knowing that someone has an interest in helping me.
Last edited on
I revamped all of my code and perfected my functions to no longer rely on information and structures derived from other classes, and it worked.
Topic archived. No new replies allowed.