After getting the track generator up and running, the next logical step was to align the player’s movement to the newly generated track. There were a few ways I considered going about this, but the simplest option was for the player to be to store how far along the track they are (from 0.0f – 1.0f), with the value wrapping every time the player completes a lap. Each frame a certain amount can be added to that value, based in part on the user’s input.
I also store how far to the left or right of center the player is on the track. I can therefore easily prevent them from falling off the edges by simply ensuring that that value is less than half of the track width.
Here’s what the movement in game looks like now. You might notice that the player movement is a bit jittery, this is a problem we are currently looking into.
You can play our first prototype build here.