'Implementing Delta Time (In Seconds) into Velocity

Using C++, SDL2, and Vulkan, I'm trying to implement delta time into my game movement by multiplying movement speed by delta time like so:

velocity += speed * dt;

I've got this code below which apparently calculates delta time dt, but I don't really understand much of it and what I need to modify in order to be able to update the velocity by pixels per second.

EDIT: SDL_GetTicks() returns the current time by milliseconds.

deltaTime = (SDL_GetTicks() - lastTime) * (TARGET_FPS / 1000.f);

if (deltaTime > TARGET_DELTATIME)
    deltaTime = TARGET_DELTATIME;
    
lastTime = SDL_GetTicks();

With a given TARGET_FPS (lets say 60 for now), and a speed of 50 pixels per second, how can I update the velocity correctly?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source