2 Replies - 881 Views - Last Post: 21 November 2012 - 08:23 AM Rate Topic: -----

#1 oOIPHiiLOo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-November 12

I would much rather have lag instead of slower game

Posted 04 November 2012 - 01:06 PM

It's quite hard to explain but basically in my game, the more things that are being printed to the screen, the slower the program goes. And when I mean slow I don't mean fps, I actually mean the program literally goes in slow motion. The larger the FOR statements, the longer it takes to register a change of the player position. I was wondering if there was some form of algorithm or concept to link the program with time and stop it from slowing down! I've posted a video on YouTube to demonstrate this better!,I want to make it so that instead of going slower, it just skips some frames and lags, however keeps a constant pace I'm also using the IDE BBC BASIC for Windows (Programming language : BASIC).

YouTube video link : http://www.youtube.c...h?v=j59SLlw2fGg

Is This A Good Question/Topic? 0
  • +

Replies To: I would much rather have lag instead of slower game

#2 modi123_1   User is offline

  • Suitor #2
  • member icon

Reputation: 14087
  • View blog
  • Posts: 56,440
  • Joined: 12-June 08

Re: I would much rather have lag instead of slower game

Posted 04 November 2012 - 01:24 PM

Rearchitecture it then. Are you tracking objects off the screen? If so why? Free up memory! For-loops - are they optimized? How is your game engine processing time? It should be fairly constant and not done on the fly or by user interaction. Who knows what is going on in your code but you!
Was This Post Helpful? 0
  • +
  • -

#3 JL29   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 50
  • Joined: 20-May 10

Re: I would much rather have lag instead of slower game

Posted 21 November 2012 - 08:23 AM

Use Delta Timing (http://en.wikipedia.org/wiki/Delta_timing)

Because you don't use it the loop will just play slower and everything will move less in more time.

The movement gets incremented by 1 every loop and the loop takes 10ms to complete. When you add more stuff the loops takes longer (let's say 100ms) but the incremented value is the same. This means that it would take 10 times longer to move the same distance.

When you implement delta timing you look at how long it takes to complete one loop and add multiply the value by that so the speed does not change. A pseudo code example would be:

Start loop
  Start Get time in ms
     position.x += 1 * delta;
  End Get time in ms
  Delta = End - Start
End loop

where delta 1 = one second and 0.5 is a half second.
This means that for every second the object moves 1 unit. If the loop takes 25ms each time to complete, the position would change by 0.025 every loop. After one second this totales to 1.

Now what if the loop takes 2 seconds to complete? Then delta would be 2 and the object would move 2 units creating the infamous lag.

This post has been edited by JL29: 21 November 2012 - 08:25 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1