i have a array 10X13. where it say 1 i want to print image called wall.

ok so the array part is easy. iam pretty sure its fine. less continue.

const int ROWS = 10;
const int COLS = 13;
int level[ROWS][COLS] =    {
    {1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,1,1,0,0,0,0,0,1},
    {1,0,0,0,0,1,1,0,0,0,0,0,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1}
};

less look at my main part of code. here iam trying to loop through array and where i see 1 paste image. i sound easy but for some reason its not working.

    dbLoadImage("wall.bmp",1); //wall
    //dbSprite(2,0,0,2);

        int x = 0;
        int y = 0;
        for(int r = 0; r < ROWS; r++)
        {
            x=0;
            for(int c = 0; c < COLS; c++)
            {
                if(level[r][c] == 1)
                {
                //dbSprite(1, x*32, y*32, 1);
                dbPasteImage(level[r][c], x, y);
                x+= COLS; 
                }
            }
            y+= ROWS;
        }

when i run this here is what i am getting.
111111111
1
1
111
111111111

but i should get some thing like this

11111111111
1         1
1         1
1         1 
1         1
11111111111

note size of 1's is not right. i should be 10x13

iam not sure but i think in dbpasteImage() i have to *32? or some thing. any thingk will be helpfull. iam stuck on this for a week.

                for(int r = 0; r < ROWS; r++)
        {
            x=0;
            for(int c = 0; c < COLS; c++)
            {
                if(level[r][c] == 1)
                {
                //dbSprite(1, x*32, y*32, 1);
                dbPasteImage(level[r][c], x, y);
                x+= COLS; 
                }
            }
            y+= ROWS;
        }

What ur doing is putting a '1' wherever the condition is satisfied right? But what ur forgetting to do is adding a space whenever its not satisfied... Which is why there is a spacing problem.. Whenever the condition for printing '1' isnt satisfied, ask the compiler to print a space... That way u'll be able to get the shape u want...

in c 's it just cout <<" "; but how do i add space in dark gdk.

if(level[r][c] == 1)
{
dbPasteImage(1,x,y);
}
else
{
 dbText(" ",x,y);    or
 dbPrint(" ");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.