top of page
Search

Functional UI

  • Zac Emerzian
  • Jun 27, 2019
  • 2 min read

Hey all!


As the name suggests, this week I was focused on making the UI functional. This means that the game can actually tell the player what lap they are on, record their best lap time, and correctly say what place they are in.


The first two were rather simple, just change a couple variables when the player crosses the finish line. However I did need to add some logic so that you can't just turn around as soon as the race starts, cross the finish line, and that be counted as a lap.


The teal diamonds are the checkpoints and the red one is the finish line.

To complete a lap, the player must cross a number of invisible checkpoints on the track in the correct order. In order for a racer's current checkpoint to be set to checkpoint 3, for instance, the player needs to have entered that checkpoint zone while they had checkpoint 2 as their current checkpoint.


It's almost like a sequence of locked doors. Checkpoint 1 gives you the key to checkpoint 2, checkpoint 2 gives you the key to checkpoint 3, and so on. And the same logic is applied to the finish line; the lap doesn't count unless the player's current checkpoint is the last checkpoint before the finish line.


The UI in the top right is now actually helpful. More player feedback when completing a lap is coming.

The trickier problem to solve was how to determine what place a racer is in. This was the solution that I liked. Each racer, including the player, has 3 variables that are important for this: - what lap they are on

- the last checkpoint they crossed

- their distance from that last checkpoint

So each racer basically counts the number of cars that are ahead of them. A racer is in front of another racer if they are on:

1. a later lap

2. the same lap and a later checkpoint

3. the same lap, same checkpoint, and are farther away from the last checkpoint


Once each racer has counted the number of cars that are in front of them, just add one to it and boom, we have our placements (eg. someone with 0 cars in front of them is in place 0 + 1, or 1st).


That's all for this week! Thanks for reading!

 
 
 

Recent Posts

See All

Comments


bottom of page