The Daily Click ::. Forums ::. Klik Coding Help ::. Racing Engine
 

Post Reply  Post Oekaki 
 

Posted By Message

Ryan▫S



Registered
  25/10/2003
Points
  161
24th January, 2004 at 01:23:37 -

anyone know how to code a racing engine which allows cpus and a player to have to complete a proper lap?

 
Gah!

cake



Registered
  13/12/2002
Points
  1173
24th January, 2004 at 06:03:41 -

Haha for this one I suggest a method I developed in my KNP days: place invisible Active Objects as checkpoints around the track and then have a system something like:

Value A of the racers is their current checkpoint
Value A of the checkpoints is their order in checkpoint sequence, ie the start/finish is 0, the next one is 1, the next is 2, etc

Value B of the racers is their current lap

Value C of the racers is their position they finish in


Create a counter called for example "FinishedPos"
Add your checkpoints to a group, say for example the group "Doors"

Then:

1.
Racer collides with groups.Doors
+ Value A of racer < Number of Objects(groups.Doors) - 1
+ Value A of groups.Doors = value A of racer + 1:

♦ Add 1 to value A of racer

2.
Racer collides with groups.Doors
+ Value A of racer = Number of Objects(groups.Doors) - 1
+ Value A of checkpoint = 0:

♦ Set value A of racer to 0
♦ Add 1 to value B of racer

3.
Value B of racer >= 5:
♦ Add 1 to FinishedPos
♦ Set value C of racer to value of FinishedPos
♦ <do other race finish-y things for the racer>

4.
Value of Finished Pos >= Number of objects(racer):
♦ <all racers are finished - do race finish-y things >

-[♦]-[♦]-[♦]-[♦]-[♦]-[♦]-

Then for you AI players, well I'll let you do that, that's the fun bit

Image Edited by the Author.

 
n/a

Daniel[Crazy_Productions]

Possibly Insane

Registered
  29/12/2002
Points
  2505
25th January, 2004 at 12:21:00 -

ive made a recing example wich also includes som basic ai, just look in my profile to find it

 
Beware of life ...so far noone have survived it.......
   

Post Reply



 



Advertisement

Worth A Click