In Jamagic you could record the laps of the players/AI, then use the pathfind object to check distance between players, if the laps are the same. If the someone is ahead a lap...well, it's obvious.
MMF has a pathfind object too. It could work on the same theory(Road being path I mean), though I don't know how you'd map your race track.
You'd also have a problem if they went off the path, since it won't be able to find a way back on then, so can't map distance if they're more than 1 "gridspace" from the road.
i really dont know if this would work but i will tell you my idea:
make a bar thing outside the playfield (track) with little squares that represent the cars, then put that if the corresponding car is moving, the square moves up (ypos - 1)... then um.. oh yeah if the squares gets to the top of the bar, that symbolizes the goal, the square gets trasnported to the beginning of the bar again. and make a thing that shoots a thing down (from the goal to the start), if the thing collides with a square add 1 to some counter.. and um, when the thing collides with the square that represents YOUR car, set the stuff that shows your position to the value of the counter or something like that.. or um.. geez its complicated and i guess not practical. well, you can chose to ignore this post if you want
Yeh pathfinding is definately the way to do it, however, I was making a mode 7 racing kart game a while back, and I certainly didn't use a grid-like map. The way I did the position was a little bit dodgey, like, only an approximation, but it was fairly acceptable:
Basically on your track you have invisible checkpoints, each with a unique value A, which is relative to their order on the track. (The start/finish is counted as a checkpoint.)
So the start/finish line has value A of 0, the next on the track has 1, the next has, 2, ..., the last one on the track has <number of checkpoints> - 1.
Each car has the values stored for them:
Lap they are on
Value A of last check point they crossed
The distance they are from the next checkpoint
The distance they have travelled since the last checkpoint
Then it is a matter of comparison, first place will have:
has greatest lap
has equal greatest lap and has greatest checkpoint
has equal greatest lap, has equal greatest checkpoint and has greatest value for (distance travelled - distance to next checkpoint).
The way I did it was I stored these values in a delimitted string in a List Object, in the format: "<lap number>;<checkpointnumber>;<value for (distance travelled - distance to next checkpoint)>;K" + "<kart number>", and then told the list object to sort itself.
Then it's simply a matter of assigning the value of the line number on which "K" + kart's number is found, to the race position of the kart .
@Biax: sounds like a good idea. It'd be solid too. I was thinking of doing a thing involving invisible checkpoints, but my idea wouldn't have worked without using 50 million objects. That distance thing is a great idea for using fewer objects and keeping an accurate record of the player's position. Thanks.
Checkpoints could have worked if you placed a checkpoint on every corner. Example: When the cars are supposed to go to the left and two cars are on the same checkpoint number, the car with the largest X position is ahead of the other car.
Edit: Sorry, didn't read the other guy's post. This has already been said Can someone delete this for me plz?
I'm trying to make it see your racing position based on who has the higher laps.
My code is this:
>always
-set counter("lap rank") to (number("opponents")+1) // +1 to include you
>if player's lap > opponent's lap
-subtract 1 from counter("lap rank")
Theoretically, the second event would check every opponent object and if it finds an opponent who's lap number is below your's it'll kick you up in your racing position.
For some reason though, MMF only checks the newest opponent object that was made. So even if you're ahead all the opponents by a lap, your lap position will still be 1 place ahead of last.
Yeh its very hard to do it if you don't abstract the values from the objects. By putting them into a list object and making it automatically sort, you don't have to do anything like that. Maybe I should make an example...I might even have my old Mode 7 racing game clunking around my hard drive somewhere