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

Author Topic: Weird movement in my program[SOLVED]  (Read 8686 times)

0 Members and 3 Guests are viewing this topic.

Sanction

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Weird movement in my program
« Reply #15 on: August 12, 2015, 12:26:38 am »
I can see how this could become a mess.. could I create a like a Init_Game() function and put that into the game constructor?
Knowledge comes, but wisdom lingers. It may not be difficult to store up in the mind a vast quantity of facts within a comparatively short time, but the ability to form judgments requires the severe discipline of hard work and the tempering heat of experience and maturity.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Weird movement in my program
« Reply #16 on: August 12, 2015, 12:37:37 am »
I don't mean to be offensive, but what does this have to do with SFML?
Maybe https://isocpp.org/ or a good c++ book or stackoverflow.net or some other "learn the language" site would be a better place...
« Last Edit: August 12, 2015, 12:39:53 am by Jesper Juhl »

Sanction

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Weird movement in my program
« Reply #17 on: August 12, 2015, 01:41:26 am »
ohh naw, He suggested a good idea so I had a question about it. I do own a few C++ books and all the SFML books.. thats how I've learned C++ over the past year. Do you have any idea why the game loop has like a gallop to it?
Knowledge comes, but wisdom lingers. It may not be difficult to store up in the mind a vast quantity of facts within a comparatively short time, but the ability to form judgments requires the severe discipline of hard work and the tempering heat of experience and maturity.

grok

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • Email
Re: Weird movement in my program
« Reply #18 on: August 12, 2015, 10:47:00 am »
I have had non smooth movement issues unitl I implemented the idea explained in this brilliant article: http://gafferongames.com/game-physics/fix-your-timestep/

One notable step is explained there in the section "The final touch". Your code snippets above don't apply that technique, so, maybe that's why your movements yet not smooth.

Let me quote an excerpt from the article:
Quote
To understand what is going on consider a situation where the display framerate is 60fps and the physics is running at 50fps. There is no nice multiple so the accumulator causes the simulation to alternate between mostly taking one and occasionally two physics steps per-frame when the remainders “accumulate” above dt.

Now consider that in general all render frames will have some small remainder of frame time left in the accumulator that cannot be simulated because it is less than dt. What this means is that we’re displaying the state of the physics simulation at a time value slightly different from the render time. This causes a subtle but visually unpleasant stuttering of the physics simulation on the screen known as temporal aliasing.

One solution is to interpolate between the previous and current physics state based on how much time is left in the accumulator

Hope that helps.

Sanction

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Weird movement in my program
« Reply #19 on: August 12, 2015, 01:56:29 pm »
I figured it out.. I was showing my FPS in command prompt but I was clearing it using system("CLS") and that created the wobble to the Game loop.

Thanks Everyone!
Knowledge comes, but wisdom lingers. It may not be difficult to store up in the mind a vast quantity of facts within a comparatively short time, but the ability to form judgments requires the severe discipline of hard work and the tempering heat of experience and maturity.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Weird movement in my program
« Reply #20 on: August 12, 2015, 07:47:13 pm »
I was showing my FPS in command prompt but I was clearing it using system("CLS")
:'(

I have had non smooth movement issues unitl I implemented the idea explained in this brilliant article: http://gafferongames.com/game-physics/fix-your-timestep/
One notable step is explained there in the section "The final touch".
The final touch does make an outstanding difference!
It took me a few reads and a break to understand it though  :-[
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Sanction

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Weird movement in my program[SOLVED]
« Reply #21 on: August 17, 2015, 04:25:27 pm »
I will come back to it after I learn the general grasp of using the SFML library. I do want to create some physics.
Knowledge comes, but wisdom lingers. It may not be difficult to store up in the mind a vast quantity of facts within a comparatively short time, but the ability to form judgments requires the severe discipline of hard work and the tempering heat of experience and maturity.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Weird movement in my program[SOLVED]
« Reply #22 on: August 18, 2015, 12:03:02 am »
When you do your physics, make sure it's inside the timestep loop; it's a part of the update section. That way, your physics should do what you expect them to. Remember that physics are based on time so you have to be in control of your time before you can be in control of your physics  ;)

You may find my small timing library, Kairos, to be useful. It includes a couple of classes that help simplify timestep usage. Have a look at Timestep Lite.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything