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 Professional Discussion / Help with F1 2D Racing Game - Waypoints with Sprites help please

Author
Message
DemonHill
18
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 11th Sep 2011 00:43 Edited at: 11th Sep 2011 00:44
I have been workign on a F1 Management game for some time.

I have never really been saticfied with the representation of cars on a track following waypoints.

I basacially calcualte the laptime of each car and offset the waypoints to make it look like the car in front is in front.

At the end of each lap the "gap" is recalculated and the offset adjusted.

I feel this can be improved and I would liek some creative advice.

Please see a video here on Youtube http://www.youtube.com/watch?v=qBZWVDwjW9Q

And the code here (apologies I am not that good at programming)



Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 11th Sep 2011 14:11
wow, there seems to be a lot of redundant code in your example that could be better implemented as arrays..

ie.



could be



Which make routines like the original example more like this.



etc

For the racing line, I've used way points also, where the car isn't attached to line, but using the current line it as a guide while moving towards the next junction (end of point on line).

If it's beyond the junction, focus shifts forward to next point and so on. To do this, you map the current point to a point along the line. While moving, each car is always trying to align itself with the direction of the way point line with some tolerance. So we're checking how far away from the line the car is, then either turning left / right.

DemonHill
18
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 11th Sep 2011 20:26
Thanks, I have no idea how to do most of what you said, but thanks for the guidance re. code optimisation. cheers

Login to post a reply

Server time is: 2026-07-11 04:44:19
Your offset time is: 2026-07-11 04:44:19