Dirty Racers

OK Guys, I'll present the reason I'm in debt with Tank Battles (the programming game I talked about). It's called Dirty Racers and it's a fast racing and combat game that I subscribed to a indie game contest that will be part of the Brazilian Simposium on Games (SBGames) this year. I've been replacing my sleeping nights with a LOT of jME and jMEPhysics2 programming and tweeking. From the lessons learnt I will be posting a TestCar.java (with related classes) any time soon for those interested in vehicle simulations.

By this time I'm using only fixed function (aka no shaders). The performance is quite nice: 250+ fps with 4 cars (9 physics dynamic objects each), per triangle collision for the terrain mesh.

Some highlights:

  • Effects are only particle systems;
  • Dome implemented from the SkyDome example from the wiki;
  • TerrainPage with procedural splatting only;
  • Each car has a different driving feeling (4wd vs. front vs. rear traction; acceleration, speed, handling);
  • Physics by JMEPhysics 2 with dynamic obstacles spread on the tracks;
  • Each track has its own feel because of the different physics material for the terrain;
  • Joystick supported (and recomended for 2 players split screen);
  • Splitscreen mode for versus race.

    Some screenshots:

    Main Menu with demo in the background:

    In game on the Desert track:

    Another track:

    …and another:

    Next I plan to use some reflection and lighting shader on the cars and a different one for the terrain with some bumpmapping, as well as applying a shadow pass.

I can do both things, and will, as soon as I fix some issues with the SFX in Windows.

At the end of the week probably.

Wow this reads and looks really great 8)

(and it's very nice to see jME Physics 2 is really used for something :D)

Good luck for that contest!!!

Forgot to mention some things:

  • This screenshots came from a Macbook (not pro) with an ordinary Intel GMA 950 graphics, so there's no anti-alias or mipmapping applied;
  • I'm using DF's StandardGame/GameStates with offline loading of assets;
  • The game has lots of sound FX as well (skidding, engine, guns), everything based on physics runtime properties;
  • The AI for the other cars is based on some ideas I got from some articles about the subject but it's already quite nice. It's quite hard to beat the AI in HARD mode.

    And last but not least:

  • I plan to make it available with full source code (unless I get hired during the conference and the job consisting of evolving it)

    Since it's acctually a framework, with some XML where you can define new cars (with models and all other parameters) and tracks, it's possible to use it for creating a lot of different race games.

Nice, any chance of a demo version later?  Also, are you using the cvs version of jME?

Renanse, actually I plan to release the full source code. If not possible, a demo at least, but that I can do only after the conference, which will happen between 6 and 8 of november.

And yes, I'm using the CVS version, but I haven't updated for some time now (couple of weeks or more) because I'm feeling NearDeployDeadlineAfraidOfChangesDisease.

Perick… it would be great to see it in action. Maybe you could post a video somewhere for us to see and enjoy. It looks extremely appealing and with lots of potential. :slight_smile:

Perhaps it would be a way to evolve it into a new kind of FlagRush tutorial  :wink:

looks pretty awsome!

Wow looks cool, would be nice to see some screen shots with anti aliasing and mipmaps applied though.  Or as others have said a video!

Keep up the good work  :slight_smile:

Can you elborate a little on your AI implementation or provide a link or two to some resources your found helpful?

perick said:

- I do this calibration by recording some laps I make myself (I'm quite good at racing games - :))

Is this automated stuff? That would mean that different drivers used for callibertion could result in different AI personalities.. no? That would be cool.. You could even automatically download AI's based on other people's driving into your own game, since I reckon they won't take too much data... (kind of Spore like)

This link is not really what I used to implement the AI, but gave me a good overview of some trends:


This one gave me a lot of ideas about my CarDriver agent and how to implement thae tracks:


The last one doesn’t really expose any implementation details, but is quite interesting.

My implementation is REALLY simple, but I liked the results and you’ll see it in action on the video I’ll post this weekend. Some things:

  • For AI cars, tracks are (as in most race games) a collection of WayPoints, in my case each waypoint is a Large jME sphere (not in the scene graph, so not drawn)
  • Each car has, at any time, a reference to the current waypoint it has to go to.
  • I only have to test collisions of the car with its current waypoint.
  • When reaching the waypoint, the car references the next one and so on.

    This is the basics… How to make it work is the key. Some more considerations:
  • Each car allways tries to turn towards the waypoint (unless trying to pass or avoid something else - later)
  • Each waypoint has an attribute with its IDEAL speed for that point (this is really necessary for the car to make tight turns)
  • Each car always acclerate to the next waypoint, and when near it brakes (proportionally to the distance) to the ideal speed.
  • This is enough to make them follow the track and make very good times… Just have to calibrate the waypoint's location and speed.
  • I do this calibration by recording some laps I make myself (I'm quite good at racing games - :))

    The style part:
  • When turning towards the next waypoint, each car steers its wheels proportionally to the relactive angle (facing direction vs. where to go to -vector3f vector3f)
  • This would make them DEADLY stable and fast, so I introduce a random style factor. Each car has a coeficient of agressivness, which makes it turn more than it needs… That makes it occilate more than others (and the same happens when trying to pass)

    The other stuff:

    Each car always tests if it'd be efficient to fire against some other in front of it. Does it when it's almost in front (so doesn't miss) and when the car is not so near, maybe staying in the way.

    When near the car in front, tries to pass, to the right or left, depending on where's the next waypoint, distance to it and hows the relactive angle between the facing and the next car.

    Since the physics are simulated, there's A LOT of randomness in all the races and the times vary constantly. The cars also have different behavior, because of the rear vs. front vs 4wd tractions and different max speeds and accelerations. But if I put one car alone (no fire hits) it's really fast and constant. That's what's expected from a good driver.

    An example, AI car laps:

    45.573s (first one, froms tart)



    My personal record in this particular track is: 43.271s

    This is the hard mode (not final calibration). For medium and easy modes I just add some speed limiter factor to apply against the ideal speed for that sector. This limiter is proportional to the position (1st has the biggest limiter), but this happens only in medium and easy difficulties. In hard mode there are no limits for the AI cars.

    Next steps will be:

    Make more than one available set of waypoints (different trajectories)

    Making the cars get better in long races, learning from mistakes (race strategy also)

    Making different CarDriver agents for each car type (parameters or some recordable learning, like neural networks)

    I think this is it.

It's not this much automated, but you just gave me an idea… :smiley:

This looks very nice! Any updates? Can we see some source? :slight_smile:

Not yet… Sources or the complete download only after the game contest which will happen between 7 and 9 of november.

I'm trying to find a nice video capture app for mac so I can post a video on some place.

Finally I found a free screen video capture app for Mac and got a video of Dirty Racers on youtube. No audio on the video yet, what’s a shame, since the audio is one of the best parts of the game.

Anyway, here’s the link for the video:


That's awesome. :)  I didn't realize that there were weapons in the game…that increases my interest in this significantly.  :-o

Thats looking really great! What are those grey blocks that you run into for? Or are they like checkpoints?

Just random obstacles. When defining a track in the xml file you can include some obstacle models, that will be placed randomly near some checkpoints.

This has been extracted from a track definition file:

<track name="Desert" circuit="true" fog="false" laps="2">

   <texture type="heightmap" file="/dados/texturas/track1-heightmap.png" />
   <texture type="detail" file="/dados/texturas/detail.jpg" />
   <texture type="screenshot" file="/dados/texturas/desert.png" />

   <texture type="image" file="/dados/texturas/new/picarra2.png" min="-128" max="128"/>
   <texture type="image" file="/dados/texturas/new/picarra2.png" min="0" max="256"/>
   <texture type="image" file="/dados/texturas/new/cement.jpg" min="128" max="384"/>

   <scale x="100" y="1" z="100" />

<!-- ERICK 42.5; OTHERS 42.7  -->
<checkpoint maxspeed="350.30377" x="749.3244" y="0" z="217.62679" checkpoint="true" angle="0"/>
<checkpoint maxspeed="350.23596" x="-320.21274" y="0" z="-1594.8516"/>
<checkpoint maxspeed="306.70154" x="-1032.3749" y="0" z="-1900.5149"/>
<checkpoint maxspeed="300.44608" x="-1788.9165" y="0" z="-1575.431" checkpoint="true" angle="210"/>
<checkpoint maxspeed="420.52847" x="-2193.9583" y="0" z="-846.0978"/>
<checkpoint maxspeed="450.95743" x="-36.148487" y="0" z="2610.8884" checkpoint="true" angle="-10"/>
<checkpoint maxspeed="356.999" x="812.64636" y="0" z="2419.4688"/>

<veggie texture="dados/texturas/cactus.png" >
   <scale x="7.5" y="10" z="7.5" />

<obstacle type="static" model="dados/modelos/container.jme">
   <position x="600" y="0" z="500" />
   <scale x="50" y="50" z="50" />
<obstacle type="static" model="dados/modelos/container.jme">
   <position x="1000" y="0" z="2600" />
   <scale x="50" y="50" z="50" />
<obstacle type="dynamic" model="dados/modelos/metalbox.jme" mass="1.25">
   <scale x="10" y="10" z="10" />

<song file="/dados/audio/elo.ogg" />
<song file="/dados/audio/janine.ogg" />


Static obstacles are placed where set, but dynamic ones are placed randomply. The number of them depends on the quality you choose in the beggining, because they are physics nodes and consume CPU power.

I'm here to announce that I'm releasing the full source code for Dirty Racers… The game got third (3rd) place in the contest and I have some plans on modding some things and creating more content to it… But I'm happy to share the code with the comunity.

The code has valuable things, but some parts are not so well organized because of the tight schedule used to produce the game. It's been conceived, developed, tested and debuged in only three months, between july and september…

Anyway, here's the link for the first version of the code… I plan to put it in a CVS or SVN and create a home page for it soon:


(edit) The zip file above is the whole Eclipse project, without the compiled classes, so you'll have to import it inside Eclipse and run the init.DirtyRacers class from there…