Sign in to follow this  
JDUK

Any idea as to why this isnt drawing my tiles correclty?

Recommended Posts

I could use some help on working out why my draw_tiles()isn't drawing my tiles right. I've out put the (test level) Level[7][7] Array to a text file and its looking like it should:
0000000
0110220
0110220
0000000
0330330
0330330
0000000
my drawtile(tilenumber, ScreenX, ScreenY) (Not to be confused with draw_tiles()) draws fine when i call it independanlty to draw any tile from my tile map to any screen position. But this tile drawing loop is giving me screwy results. Its meant to draw the 7x7 tile map into the isometric dimond shape on screen.. but it just draws them all over the place. mostly grouped into a semblance of somthing kind of retangular ... but patchy
void draw_tiles()
{       
    int XStart = 0;// X Position in the Level array to start drawing from.
    int YStart = 0;// Y Position in the Level array to start drawing from. 
    int Row_StartX = 0; // X Position on screen to start drawing a row of tiles from.
    int Row_StartY = 0; // Y Position on screen to start drawing a row of tiles from.
    int XIncrement = 0; // Increment added to X Position to find start of new line
    int YIncrement = 0; // Increment added to Y Position to find start of new line
    int X = 0; //Increment added to draw next tile in the row
    int TiW; //Tiles In Width (To be drawn)   
    
    for(int i = 1; i <= (TilesInWidth*2)-1; i++)
    {
            
            if(i <= TilesInWidth)//Draw the upper half of the map.
            {
              XStart = 0;
              YStart = (i-1);
              TiW = i;
              XIncrement = -16;
              YIncrement = 8;
            }           
            else  //Draw the lower half of the map.
            {
              XStart = i - TilesInWidth;
              YStart = TilesInWidth -1;
              TiW = TilesInWidth - (i - TilesInWidth);
              XIncrement = 16;
             
              
            }
            
            for(int j = 0; j <= TiW; j++)
            {
                    draw_tile(Level[XStart + j][YStart -j],Row_StartX+X,Row_StartY);
                    X += TileWidth;
                   
            }
            X = 0;
            Row_StartX += XIncrement;
            Row_StartY += YIncrement;                      
    }
}






one of two things is happening ( I think), it either: 1) Im missing somthing really simple or 2) That loop is pure junk (I'm betting on this one) [Edited by - JDUK on November 10, 2005 11:47:15 AM]

Share this post


Link to post
Share on other sites
Woohooo Done it...
Damn that code was buggy as hell... the idea was right but some of the numbers where off .

Lesson learnt: tiny mistakes here and there soon mounts up to a big problem.

:D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this