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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Lillu

Pages: [1]
1
System / Re: Am I using the sf::Clock/sf::Time correctly?
« on: February 01, 2015, 08:51:42 pm »
Interesting article. I'll see if I can implement this and thanks for the tip about vectors.

2
System / Am I using the sf::Clock/sf::Time correctly?
« on: February 01, 2015, 05:13:16 pm »
So to start of with: I'm fairly sure that I am, but just trying to cover all my bases.

I'm trying to implement a frame rate independent acceleration based movement system.
The code that I have so far is as follows:

void Actor::Update(sf::Vector2f GravityStrength){
    float UpdateTime = UpdateTimer.restart().asSeconds();
   
    //Apply Gravity To velocity
    ModVelocity(UpdateTime,sf::Vector2f(GravityStrength.x * Weight, GravityStrength.y * Weight));

   
    //Checks for collision and moves the actor.
    ComputeMotion();

}

void Actor::ModVelocity(float UpdateTime, sf::Vector2f Mod){
    Velocity.x += Mod.x * UpdateTime;
    Velocity.y += Mod.y * UpdateTime;
}

This results in the actor falling at double the speed if I double the frame rate, but if I set the Velocity to 0 at start of the "Update" function the falling rate becomes constant regardless of the frame rate. This leads me to believe that I'm using SFML correctly and there is just something wrong with the overall logic, but just asking to be sure and in case any of you would willing to help with a more general problem.

Pages: [1]
anything