Basic top-down movement physics
I haven't watched all the videos in the classroom yet, but I noticed that Randy mentioned that better movement physics is difficult, which it can be, but it doesn't have to. You can get away with just having a velocity vector, a position vector, movement speed, and friction. The friction makes sure the player can't get infinite velocity and makes sure the velocity doesn't get set to 0 immediately after you stop pressing any input buttons. Though you could have a max speed and clamp the player velocity, you could do this using the clamp macro in linmath.c. For example: // Globals / state #define MOVEMENT_SPEED 20.0f #define MOVEMENT_FRICTION 50f Vector2 velocity = v2(0, 0); Vector2 position = v2(0, 0); // Get the input direction. Vector2 direction = v2(0, 0); if (is_key_down('W')) direction.y += 1; if (is_key_down('S')) direction.y -= 1; if (is_key_down('A')) direction.x -= 1; if (is_key_down('D')) direction.x += 1; // Normalize the direction. direction = v2_normalize(direction); // Scale the direction to the movement speed. direction = v2_mulf(direction, MOVEMENT_SPEED * delta_t); // Include new movement in velocity velocity = v2_add(velocity, direction); // Apply friction velocity = v2_mulf(velocity, MOVEMENT_FRICTION * delta_t); // Set velocity to 0 if too low if (v2_length(velocity) < 0.1f) velocity = v2(0, 0); // Apply velocity position = v2_add(position, velocity); Believe it or not, but that is all you need to have some basic movement with acceleration and deceleration. If you want to make it a bit more fancy you could for example only apply the friction when there is no input (when the length of direction is 0) so it only decelerates when you aren't moving, and you can better control the movement speed, but then you should also set a max speed using clamp.