i am working on a paltform game while i learned SDL and game programming in general. I already had snimation, gravity, jumping, map scrolling and collision on my old computer, and decided to restart the coding because it was messy and it would have been an hassle to get the code to my new computer. So far i have animation, gravity and collision in the game, but before i do anyhting else i wanted to nail tile maps. So far i can draw individual tiles and set a SDL_Rect to them as collision, but i am stumped with collision with a array tile map.
Befoe i post some wiked awesome code =] Ill tell what i thought might have worked, in case it COULD work, but i was doing something wrong or forgetting something. On the build on my old computer i could draw tiles and a single Rect assigneed to each tile, but the Rects were the same. If it doesnt make sence, this is an example :
Code: Select all
drawthings( 50, 35, wall, &block );
drawthings( 20, 50, invisiblewall, &block );
Code: Select all
for( int x = 0; x < 15; x++ )
{
for( int y = 0; y < 20; y++ )
{
if( map[y][x] == 1 )
{
draw_surface( x * 32, y * 32, wall, screen );
}
}
}