• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Race mini-map progress bar?

Hiya!

I'm tracking to make a simple line-based mini bar (or progress bar) for a short 1 vs 1 race to the goal.
I want the the mini map (to be be display at the bottom of the screen) to show how close both player 1 and player 2 are in relation to the goal.
A quick mock up:

upload_2019-12-7_12-56-29.png

I'm not worried about basic drawing code. My main concern is how to calculate a racer's progress. The tracks are not a straight line, but have turns and twists. How could I be able to determine the racer's relative progress
to the goal?

the track for reference. top left is start, bottom right is end
upload_2019-12-7_12-59-18.png
 

samspade

Member
If the racers can't leave the track and the individual track segments are straight, then the length is the sum of all track segments which can be calculated with point_distance from the start and end point of each segment and the player's distance is calculated the same way.

It's hard to say exactly without knowing what the rest of the code looks like but I would probably create a list of points, where each point is an x/y position and you can then just loop through everything to get the total track length and for the players do the same. The only difficult part would be finding the player's position. One way would be to use the closest normal point. Alternatively you could check for positions in rectangle or something like that to determine which portion of the path they were on.
 

Fabseven

Member
You could create some obj_check each 100 px of the track, this obj's height should be the same as track, when player is in colision with this obj then player.position += 1
then your timebar will be upgraded, 100% = number of obj_check. Reset player.position to 0 when you change turn.
 

Binsk

Member
@samspade Basically stated what I was about to.

On my last racing game (a long time ago) I effectively had "waypoints" along the track. In my case this was mostly for vehicle respawn but it worked for calculating who was in the lead as well.

Take the measurements at the start between each waypoint to get the overall track length. As the players race, find the next waypoint on their path and calculate the distance to it plus the distance for all remaining waypoints. Subtract this from the overall track length and you have the location in the race that the player is at.

The accuracy depends on how you lay out your waypoints.
 
Top