Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Cars - keeping them on track

Author
Message
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Apr 2003 21:36
Does anyone have any suggestions on how to keep computer controlled cars on track? Or any other tips relating to racing games?
Thanks in advance.
All the Best,
StevieVee
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 18th Apr 2003 22:09
probably give them waypoints spaced every so often about your track, enough of them to keep the cars from cutting corners. Then smooth the turning toward eack one using the newx/yvalue and curveangle commands.

You could make a waypoint array to store the coordinates of each waypoint, and have also a curve factor in the same array, so that each waypoint gives you a coordinate and a curve that will take your cars smoothly from one waypoint to the next.

With the addition of collision you could make something pretty convincing that way, but of course it's the crash physics that are the difficult thing

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Apr 2003 23:59
Thanks for the info. CurveAngle will be next on my list of commands to research. At the moment I'm using POSITION OBJECT, will this be compatible with CurveAngle?

I've read the help, but it's very brief.

Thanks in advance.
All the Best,
StevieVee
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 19th Apr 2003 00:41 Edited at: 19th Apr 2003 02:18
I know, but the best way really is to experiment.
There's very little you can do wrong in the cli editor, practically all the commands are compatible through the use of variables

The flow would be real simple, like

1*car on starting line, waypoint 0
2*car recieves data from waypoint array, and moves forward, gaining speed.
3*car curves it's y angle, based on data recieved -the angle to the next waypoint from this one and step value to curve.
You'd work wout the best values through trial& error, unless you know your trig. You can also apply the curve to the yangle of the front wheel limbs.
4*car hits waypoint 2, same process as before.

*Special condition
If a car collides with another,
find get the next waypoint position from the array, store the car's current angles, use point object to point the car towards the waypoint, store it's y angle, now rotate it back to where it was, and put the new y angle into the curveangle angle variable
increase the step value of the curveangle command to compensate for the collision, once there is no longer a collision.
That way it'll turn back towards the waypoint more quickly and hopefully stay on the track

there are of course always other ways
If you don't care about smooth curves, you could simply use the point object command to point the car, without curving it slowly.

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Apr 2003 01:49
Danmatsuma, you're turning my oh so average application into a masterpiece!

It'll take a while to implement everything, but as an experienced programmer who is completely new to games programming you're advice is spot on. Cheers m8, you'll be in the credits.

BTW, it's not a car racing "game" as such, I'm trying to create an application that generates random races, with an AI system that can create unpredictable results.

Thanks in advance.
All the Best,
StevieVee
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 19th Apr 2003 02:20
hehehe I'll be interested to see it in action, maybe you could make it into a small online game where you can bet real money on the outcome, course you'd need to make all the drivers gorgeous women..

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.

Login to post a reply

Server time is: 2025-05-16 20:50:34
Your offset time is: 2025-05-16 20:50:34