# Approaches on 2D top-down track racing visualisation

I'm considering writing a very simple management style game with the theme being motorsport racing.

I've got a good idea how to do the 'management side', but the issue I'm having is how to visually render cars and move on a track (something a bit like):

The key points (keeping it simple):

• the user won't control the vehicle directly, they are the 'manager' (think football manager) - they can decide on a strategy but cannot control the vehicle
• the car should stay on track (visually) - they may 'crash' (along with other events) though
• the speed it goes around the track is determined by vehicle performance
• a car will be aware of other near-by cars around the track - for example, if they're about to be overtaken, they may actually do a slower lap as they are defending - they may collide, along with other events

My initial thoughts are there are two key design elements here, the track and the car.

The track:

• a track is composed of many segments
• each segment is stored in an array
• a segment (I'm not entirely sure here) but one thing it might contain is a 2D array:

(From [this](https://gamedev.stackexchange.com/questions/149966/approaches-on-2d-top-view-racing-game-track-design) answer gave an approach of using multi-dimensional arrays)
_ _ _ _ _ _ _ _ _ _
| d d x x x d d d |
| d d r r r d d d |
| d d r r r d d d |
| d d r r r d d d |
| d d r r r d d d |
| d d r r r d d d |
| d d r r r d d d |
| d d e e e d d d |
| _ _ _ _ _ _ _ _ |

_ _ _ _ _ _ _ _ _ _
| d d x x x d d d |
| d d r r r d d d |
| d d d r r r d d |
| d d d d r r r e |
| d d d d r r r e |
| d d d d d d r e |
| d d d d d d d d |
| d d d d d d d d |
| _ _ _ _ _ _ _ _ |


Above is a straight and a 90 degree corner - x exit, e entry, r racetrack and d dirt. Maybe I could create a bunch of these and create a track.

Or maybe a simpler version where I define just an entry and exit:

_ _ _ _ _
| d e d |
| d r d |
| d e d |
| _ _ _ |

_ _ _ _ _
| d x d |
| d r e |
| d d d |
| _ _ _ |


The simplified version where I define an entry e and exit x. I can add additional points r and then construct a curve/straight-line based on the x, e and r coordinates?

My idea is that the vehicle will then move across each segment and I can calculate the time it takes to complete that segment. I can then add up all segments which will give me the lap time. With this approach, I can also check the previous/current/next segment to determine if there are other vehicles it needs to defend/attack against.

The car:

• store all vehicles in an array
• each vehicle will always be in a segment
• speed it completes the segment is determined by its performance (and segment characteristics)
• vehicle can 'see' if there are other vehicles in previous/current/next segment and decide whether to overtake/defend.

I think I could make this work, but I'd be really interested to know if there are better/simpler approach - bearing in mind it's mostly a visualization and the speed and events are determined by my program.

• For the level of detail shown in your example image, it would probably suffice to use a spline instead of a tile-based approach. Aug 24 '20 at 20:38
• What engine are you using? Aug 24 '20 at 20:47
• Not decided on engine yet @Kevin - but Unity is a possibility Aug 24 '20 at 20:51