0

I've been developing a platformer engine in XNA for a short time now, and I decided to see how what I had so far ran on my laptop (not what I'm developing the game on.) I've been getting some strange latency (when changing direction and walking/jumping), as well as a bit of lag. I've asked a friend to run it on his computer and he gets the same result, but on my desktop it's fine. Any thoughts?

I initially thought it may be something to do with different graphics cards, because my desktop has a relatively powerful one and the computers with these problems have integrated graphics, but as it's a small 2D game I wouldn't think there would be problems like this.

l'-
  • 131
  • 5
  • You should profile your code. There is a Visual Studio Ultimate trial version free for 90 days, you might wanna try using it to find out which piece of code causes the slowdown. Other than that there might be nothing to suggest. – user1306322 May 12 '13 at 06:50
  • Actually, there are a few things. First, fill out your profile to give us some information about yourself, such as your level of experience with XNA, C# or any other things that may ever help give the community an idea what you may be missing or overlooking. And you might want to include the fragments of your code responsible for moving to the left and right into your question. That sure does help when asking to find a problem related to code. – user1306322 May 12 '13 at 06:53

1 Answers1

0

Profiling

You will want to profile you code to see what parts of it are taking the longest, there are many profilers you can use.

There are other questions dedicated to this.

Once you have one up and running, you will probably want to install it on 2 computers to see what causes it to run slow for each.

Timesteps / Framerate

Anouther thing you may want to play around with is

IsFixedTimeStep = true/false
graphics.SynchronizeWithVerticalRetrace = true/false

I messed around with changing them and depending on the situation it makes it smoother and less laggy

Elapsed Time

And lastly, you may already be doing this, but always apply elapsed time to your movement.

DONT do this.

position += velocity;

DO this.

float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
position += velocity * elapsed * speed;
Community
  • 1
  • 1
Cyral
  • 13,999
  • 6
  • 50
  • 90
  • Thank you! I've tried messing around with IsFixedTimeStep, but not SynchronizeWithVerticalRetrace. Turning VerticalRetrace to false and IsFixedTimeStep to true solved my problem. – l'- May 12 '13 at 17:49