Announcement

Collapse
No announcement yet.

Question about ticks, canvas and fps

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Question about ticks, canvas and fps

    While tweaking with optimization in our game, I've noticed that GUI stuff drawn with canvas react differently than other stuff that happens ingame when the FPS is low.
    For example: A pawn will use exactly the same time moving from A to B, regardless of the FPS being 60 or 20. However, if I have a image drawn with the canvas, moving across the screen (by updating the screen coordinates per canvas-tick), it moves much slower when the FPS is low.

    Although I can see the logic for both cases provided that the same was true for both, I can't understand why they react differently. Can someone explain to me how it works?

    #2
    K it depends how u are moving the image.
    For instance if u just add 5 on every frame,
    At 20 fps it will move 100per second,
    At 40 fps it will move 200per second.
    Now to avoid this you want to figure out
    How much it should move on each frame
    Given a speed. So say you want to move
    100 units in 1 second. Then you would do
    Current + 100 * deltatime;
    The delta is the current time - the last render time
    That will make it move at a constant time ni matter
    The fps. Now on a side note. To alter the time
    You have to use the inverse. So to get 100 in 10 seconds you would add a * 1/10 to the previous equation.

    Comment


      #3
      Though on a side note its easier to figure te inverse your self than making the engine do it.
      Some examples:

      2 is 0.5
      0.5 is 2
      10 is 0.1
      0.1 is 10

      The reason behind this that it has a reverce relation to time. So greater speed = less time greater time = less speed
      and i have found divisions to be tricky when combining them into an equation, at least on canvas anyhow
      Hope this clears up any questions and any corrections are welcome

      Comment


        #4
        Thanks for the information I will try it out soon.

        Comment


          #5
          You can always multiply by deltatime so that it will always be in-sync.

          Comment


            #6
            Well if you
            Are doing this on a hud class, i believe
            The delta is held on a float called renderdelta
            So that would save u time doing the whole
            Timeseconds - lastrender

            If not you can do the calculation manually
            Or some functions alredy have that as a parameter
            Like the tick function

            Comment

            Working...
            X