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

Author Topic: Slow-motion lag problem  (Read 1444 times)

0 Members and 1 Guest are viewing this topic.

wolfpw

  • Newbie
  • *
  • Posts: 2
    • View Profile
Slow-motion lag problem
« on: March 22, 2014, 02:31:25 pm »
Good day everyone!
I made a platformer, but when I set enemies on my map through TiledMapEditor (I use loading map from XML file) I have a trouble, game start lag as in slow motion, but when I  kill them in game lag stops. I think it's because of less memory that code allowed to use. How to set more memory for my code(I use VS  c++ 2012) or fix this problem?
Thanks alot

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Slow-motion lag problem
« Reply #1 on: March 22, 2014, 02:34:34 pm »
The RAM is hardly the problem.

You should find out the real performance problem with a profiler, or at least some time measurements. Maybe you are unnecesarily copying large data structures or SFML resources?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Slow-motion lag problem
« Reply #2 on: March 22, 2014, 02:39:13 pm »
If I was to guess, I'd say you are probably doing an excessive number of draw() calls. Maybe check that you are only drawing visible parts of your world. Maybe some parts can be drawn more efficiently with a VertexArray rather than many sprites?
Just guessing.

As has already been suggested; use a profiler to find out where time is spent.

Also make sure you build with optimizations enabled.

wolfpw

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Slow-motion lag problem
« Reply #3 on: March 22, 2014, 07:30:43 pm »
I deleted drawing of my objects, but it lag too, I think because they actie, not because its hard to draw them :(
Found a hint, Thanks for replies, I just modified my code: I set all interactions with my objects only if the visible at window right now. And lags gone, thank you all so much!
« Last Edit: March 22, 2014, 07:36:29 pm by wolfpw »