2D Racing simulator

I recently got the crazy idea that it would be fun to try to create a 2D racing simulator and, because I'm crazy, that's exactly what I've started working on.


I made a general plan of how it should roughly turn out to look and work. My main idea is that the car should be controlled with a game pad (or a wheel) because I'm hoping to achieve at least somewhat decent physics.


I'm not sure if I will ever finish it and how much time I can invest in it, but I'll see how far I get.


The first step that I wanted to take was to create some simple tracks. Because I'm both shit at artwork and lazy I decided to go with procedural generation for tracks, which is what the following video shows (the early steps of it).

[video=youtube;p2Ez23q3GgQ]https://www.youtube.com/watch?v=p2Ez23q3GgQ[/video]


I generate some random points which I order based on the clockwise rotation and distance from the center of the screen. Then I move the points about a bit so that they're not too close together and that the angle between two points is not too small. Despite this there are still intersections sometimes and corners that are too tight, but I think I know a way to detect these.
The smoothing is done with a Catmull-Rom algorithm.


The next step would be to create a road surface with a certain width around the outline, which will be then be scaled up to provide the view while driving.
 

Kenadian

Staff member
Site Admin
lol I'll watch this with enthusiasm but I think you should definitely consider scaling back the "hairpin" algorithm.

...also, a variable speed S would be nice; maybe a fast in slow out S would be a welcome change.

Lastly, it would probably be nice if you had a higher speed turn in to the straight stretch so people get to see passing under acceleration. Okayama has a good example of a final turn that if handled correctly can make for some interesting racing down the straight.

I'm assuming that's where most of your Grandstand will be so you certainly want to give the audience a good show IMHO.

Good luck!
 
Yeah, it's going to need a few parameter changes, for sure.

Esses with different features seems like a good idea, I was also thinking about adding a chicane here and there on a straight bit. A high speed last turn should also be possible I guess but it isn't the highest priority for me. Tracks like Laguna Seca and Mt. Panorama have slow corners before the finish for example and they're good passing opportunities.

It stays a random generation of course, so the idea is that any user can generate a (drivable) track and if you don't like it, you can press a button and it will create a new one.

I will keep updating here as I make improvements.
 

Wapwap

Staff member
Admin
Good luck! Sounds like a very interesting concept. There's not a whole lot of games in this genre. Can't think of any games that focus on realism.
I remember playing games like Death Rally and Micro Machines a long time ago. Probably not very comparable, but I suppose that in the essence it will be the same? Obviously with more realism and sim-like.
 
I checked out those games and the point of view will be similar. The problem with those games is that you can't really see ahead of you because of the viewpoint but they make up for it by high turning speeds and short braking zones (or none at all).

I hope to provide enough sight ahead by placing the car on the bottom of the screen and keeping the car (somewhat) static while moving the environment around it, which is essentially what all racing games do in which you use a chase camera or cockpit view.
 
I still had a video of an update lying around:
[video=youtube;wzTVahjnWLI]https://www.youtube.com/watch?v=wzTVahjnWLI[/video]

As I was adding the edges of the track I ran into a slight problem, as you can see in the stage where the green and red lines are visible. The corners create intersections and it took me a while to figure out how to reliably get rid of them.

At this point I have an enclosed track and was able to colour the actual track surface. Many corners remained pointy/jagged and again it took me a while to figure out how to deal with that. I ended up drawing a small circle on every pixel on the screen and stored where I could draw a full circle without overlapping the road surface. The remaining pixels that could not fit a full circle were added to the road surface to smooth out the corners. It is a computationally heavy approach but it works.

At the end I show a (very) simple scaled up automatic test run. I know, the car is very realistic and it cost me months to model :). And no, I didn't ask Wapwap to provide the driving line, it's just following the original center line of the track.

I'm not too happy with how it looks at a bigger scale, even without any detail added to it. The track's edges are blurry. The rotating itself is not smooth because the car essentially jumps from point to point but that can easily be improved.
I could maybe improve the look of it by increasing the resolution of the track map or by seeing if I can improve the scaling somehow. Next to that I'm not sure if you will able to see far enough ahead, taking into account braking zones.

I do plan to continue working on it, but I'm also working on something else at the moment, so I'm not sure when that is.
 

Twitch

Latest posts

iRacing Special Events 2026

ROAR: LMP3, GT4, Touring
  ~ Jan 9 - 10
Daytona 24: GTP, LMP2, GT3
  ~ Jan 16 - 18
Bathurst 12: GT3
  ~ Feb 20 - 22
Sebring 12: GTP, LMP2, GT3
  ~ Mar 27 - 29

Forum statistics

Threads
3,845
Messages
48,118
Members
628
Latest member
HarperAdams
Top Bottom