The Daily Click ::. Forums ::. Klik Coding Help ::. racing position?
 

Post Reply  Post Oekaki 
 

Posted By Message

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
22nd April, 2004 at 17:41:21 -

I'm making a Mariokart style racing game by the title, "Neonair Racing." Yes, I'm using Mode 7, but I've figured that out ,and made an AI, etc.

I need help making it display which position you are in in the race(1st,2nd,3rd, etc). I have no idea how this could work.

Any ideas?
That's pretty much all I need to complete the main engine for the game.

 
n/a

Kramy



Registered
  08/06/2002
Points
  1888
22nd April, 2004 at 17:52:07 -

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.

Goodluck though.

 
Kramy

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
22nd April, 2004 at 19:05:02 -

I have no idea how the path finding extension works.

How do I use it?

 
n/a

:JULI@N:



Registered
  14/07/2002
Points
  641
22nd April, 2004 at 23:46:23 -

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

 
n/a

cake



Registered
  13/12/2002
Points
  1173
23rd April, 2004 at 00:45:23 -

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 .

Did I make sense? lol

Image Edited by the Author.

 
n/a

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
23rd April, 2004 at 06:35:31 -

@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.

 
n/a

Shme (Stupid Liar)

Too late to fornicate

Registered
  05/11/2002
Points
  574
23rd April, 2004 at 07:52:57 -

great system biax.

 
Stinkiest click stuff
http://www.skunk-e.cjb.net

X_Sheep

I had a custom rating before it was cool

Registered
  01/03/2004
Points
  1313

VIP MemberPicture Me This -Round 23- Winner!Dos Rules!
23rd April, 2004 at 11:07:32 -

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?

Image Edited by the Author.

 
a/n

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
23rd April, 2004 at 18:28:26 -

I've got another problem now.

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.

Any ideas?

Image Edited by the Author.

 
n/a

cake



Registered
  13/12/2002
Points
  1173
23rd April, 2004 at 22:00:58 -

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

 
n/a

Kramy



Registered
  08/06/2002
Points
  1888
24th April, 2004 at 17:45:34 -

Seems like it'd be simpler to just learn the pathfind object. *Shrugs*

 
Kramy

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
24th April, 2004 at 18:46:14 -

Aha! I figured it out. Thanks a bunch anyways guys.

Here's an example I made: http://www.clickteam.com/CTforum/showflat.php3?Cat=&Board=fac&Number=236032&page=0&view=collapsed&sb=5&o=&part=&vc=

 
n/a
   

Post Reply



 



Advertisement

Worth A Click