1 Replies - 454 Views - Last Post: 14 January 2014 - 11:32 AM Rate Topic: -----

#1 MrSato  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-January 14

SDL and c++ - Problem with tile map rendering to screen

Posted 14 January 2014 - 10:51 AM

ok so ive been trying to find the error in my logic for a couple days now, im still new to programming but this seems to be the fun way for me to learn.

Im reading from a file, putting it into a map[y][x], yet when it draws the map to the screen it seems at random.

the text file is a basic 0 1, either a brick or no brick. but the bricks seem to be placed at random.

Map map; 

    int x = 0, y = 0;  
    
	ifstream input( name );

               while (input)
               {
                     
                 input >> map.tile[y][x];
                 cout << map.tile[y][x];
                 x += 1;
                 if(x >= 30)
                 {
                         
                         x = 0;
                         y += 1;
                 }
               }  
               input.close();












Map map;

	int x, y;  
  
    for (y=0;y<mapMaxY;y++)  //start drawing the map
    {  
        for (x=0;x<mapMaxX;x++)  
        {  
            if (map.tile[y][x] != 0)  
            {   
				gameDraw(0, 0 , x * mapTileSize, y * mapTileSize, mapTileWidth, mapTileHeight, renderer, brick);
				
            }  
		
		}

    }  


thanks for any help you can give me.

Is This A Good Question/Topic? 0
  • +

Replies To: SDL and c++ - Problem with tile map rendering to screen

#2 MrSato  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-January 14

Re: SDL and c++ - Problem with tile map rendering to screen

Posted 14 January 2014 - 11:32 AM

nevermind, a little more work and i have it!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1