Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: filling the window with a texture  (Read 1498 times)

0 Members and 2 Guests are viewing this topic.

Puchaczov

  • Newbie
  • *
  • Posts: 1
    • View Profile
filling the window with a texture
« on: November 25, 2011, 06:02:41 pm »
hi everyone, i've got a problem with filling the window. This is my code:
Code: [Select]

void textureStore::drawMap()
{
    unsigned int temp=0;
    int zm=50;
    sf::String text;
    for(int i=0; i<Y; ++i)
    {
        for(int j=0; j<X; ++j)
        {
            screen->Draw(spr[0]);
            spr[0].Move(50,0);
            temp+=50;
        }
        spr[0].SetPosition(0,temp); //it isn't working!
        screen->Draw(text);
    }
}

I try to start new line (spr[0].SetPosition(0,temp)) and it isn't working. The only first line is filling with texture. Why and what should i do to make it working.

sbroadfoot90

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
filling the window with a texture
« Reply #1 on: November 25, 2011, 09:46:01 pm »
Can you use proper variable names? Maybe then you can work out what is wrong. Using a one or two letters or temp for variable names makes your code really difficult to read and subsequently you aren't able to track the logic of your code properly.

As far as I can see, whatever X is, after the first time the inner loop completes, temp will be X*50. This is probably off the screen.

Also, you don't use zm at all.

Next time, you can simply output the value of the variables used in the line that "doesn't work" for you just before they are used. Eg

Code: [Select]

cout<< temp << endl;
spr[0].SetPosition(0,temp); //it isn't working!


Either that, or use a debugger.