Quantcast
Channel: Question and Answer » game-loop
Viewing all articles
Browse latest Browse all 30

How to use multiplication operation in game render delta time?

$
0
0

We are using delta time like this:

private static final float SPEED = 200f; // Moving pixels in one second

@Override
public void render(float delta) {
    myObject.vx += SPEED * delta;
    myObject.vy += SPEED * delta;

    myObject.move();
}

So I am using this update method to apply friction on my object:

private static final float FRICTION = 0.98f;

@Override
public void render(float delta) {
    //...

    myObject.vx *= FRICTION;
    myObject.vx *= FRICTION;

    myObject.move();
}

I know this is wrong:
myObject.vx *= FRICTION * delta

I want to use friction with “multiplication operation” not “minus”.

So how can I implement the delta time to my FRICTION variable?


Viewing all articles
Browse latest Browse all 30

Trending Articles