18 minutes
Rules and Scoring
The road is at war now. Rammers, shovers and gunners come for you, the police chase you, and a bomber drops bombs where you are going to be. None of it counts. Nothing keeps score, and you can't lose: a wrecked car burns and drives on. The truck and the bomber only come when you press your own debug keys.
This lesson adds the rules of a run. They all live in one component, AutoRunnerDirector, on the Game entity.
A point a metre
The score pays a point for every metre of road (pointsPerMetre). Points are whole numbers, and a car moves less than a metre a frame. Flat out, your car does 52 m/s. At 60 frames a second, that is 0.87 m a frame.
Round each frame's 0.87 m down and it pays 0. The next frame pays 0 too. Ten seconds flat out pays 0, and so does a whole afternoon.
The fix is to keep the part you could not pay yet, and pay it next time:
Say you drive at 30 m/s, so each frame is half a metre:
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.