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

Author Topic: sfml background lagging  (Read 2612 times)

0 Members and 1 Guest are viewing this topic.

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
sfml background lagging
« on: June 01, 2015, 07:00:33 pm »
I already tried everything, update my driver to the latest, running under release mode but still when theres background in my game its lagging my game.

any solutions?



DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: sfml background lagging
« Reply #1 on: June 01, 2015, 07:24:34 pm »
If you dont post details of what you call "lagging" few we can do bro,
I would like a spanish/latin community...
Problems building for Android? Look here

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: sfml background lagging
« Reply #2 on: June 01, 2015, 07:29:58 pm »
@DarkRoku

its slowing down my game, like the fps is getting low

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: sfml background lagging
« Reply #3 on: June 01, 2015, 07:38:41 pm »
Bored people could try to guess for a while (ie: "load the texture only once, not every frame") or you could provide us with more information: source code and clear description of the problem (how much is "low"?).

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sfml background lagging
« Reply #4 on: June 02, 2015, 01:58:43 am »
We don't even know what your background is - a single image, tilemap, vector art, solid colour...

I already tried everything
I feel it necessary that I should point out that your statement is factually inaccurate.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: sfml background lagging
« Reply #5 on: June 02, 2015, 10:11:35 am »
Heres my game background see the picture below,

heres the code:

int main()
{
     sf::RenderWindow window(sf::VideoMode(500,500),"SFML TEST");
     
    sf::Texture texture;
texture.loadFromFile("images.png");

sf::Sprite sprite(texture;

while(window.isOpen())
{

//events
     sprite.move(-1,0);
    window.clear();
   window.draw(sprite);
   window.display();
}

}

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sfml background lagging
« Reply #6 on: June 03, 2015, 01:15:21 am »
Please use code tags i.e. [code=cpp] (code goes here) [/code]

In your code, the sprite you are displaying is moving one pixel to the left each frame/cycle. What problems are you having?

Note that frame times are inconsistent so it would be better to move by an amount multiplied by the amount of time passed.
Add before the main loop:
const float scrollSpeed = 100.f; // pixels per second
sf::Clock clock;

Then, change the move(-1, 0) to:
const float frameTime = clock.restart().asSeconds();
move(-scrollSpeed * frameTime, 0);

Then, let us know if that fixes the problem or you are still having troubles and let us know what those problems are.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything