How is ball_pos calculated

I'm new to game development and I'm trying to build my first Pong game on the Godot engine. the tutorial I'm following is given below.

Simple Pong Game

What I don't understand is the line:

ball_pos += direction * ball_speed * delta

How is the new ball position being calculated?

As far as I know, delta is the time elapsed in seconds (float) since the last _process() call.

Also, why is the direction vector set to (1.0, 0.0)?

I'm looking for a clear explanation since the tutorial doesn't explain much. Thank you.

• Direction * Speed * DeltaTime = Velocity * DeltaTime = DeltaPosition Jul 10 '17 at 19:08

The += operator adds the right hand operand to the left hand operand. So the line is equivalent to

ball_pos = ball_pos + direction*ball_speed*delta

So direction*ball_speed*delta is the offset of the new position compared to the old position. It's the distance the ball travelled during this frame. direction*ball_speed is the speed of the ball combined with its direction, so it's a vector. Direction is a so called unit vector, so its length is one. This represents the velocity of the ball in (some distance-unit)/second. If you multiply this by the time that passed since the last update you have the change in position in this frame.