This process of building the AI for the enemy racers went at least 90% smoother than I thought it would have. Either I’m getting good at this programming thing or I just got lucky. Take a look at the video.
It’s rather simple, really. For each level, I create a map of “waypoints” for each of the enemy cars to follow. Once they hit one waypoint, they move onto the next. To make sure that they all don’t follow the same path, I used Math.random() to add to the x and y location of the waypoints so each car’s destination is different than the others. Maybe one lap a certain car will go into a turn perfectly but then the next lap he’ll go skidding into the dirt, who know? LOL!
Once I saw that the cars were able to navigate from point to point, I just basically copy and pasted the code from the player and whalla, they started to accelerate, brake, and turn. Magic, really.
To Do List:
- Obviously the AI isn’t completed. There’s that annoying depth issue where the cars just drive through eachother. To fix this, I’m going to code in a way to figure out what car is driving over who, and to adjust the depths of the two cars so it looks like one is driving on top of the other. This idea comes purely out of the Sega Genesis game I’m basing this whole project on, Combat Cars.
- Next, I have to get the AI to know when to use their own unique weapon. If there’s an open opportunity to take out an enemy vehicle, take it!
- After that I want to update/get new sounds for everything. I want to find the perfect sound for everything.
Well, that’s it. Whatcha think so far?



Paul D'Amora decided to grace the world with this comment:
Seems a little short. The small track doesn’t give the game a chance to build up suspense and multiple chances to win or lose.
Also, I think you should try to do something about spreading out the cars. Try giving the enemy cars varying speeds ( so their speed would be a random integer between two numbers, or speeds). That way, while the the players speed is consistent, the enemies have slight differences in speeds that will cause some to be faster than others, which will cause the cars to be more spread out, which will give the cars a chance to use his weapon in a tactical way, instead of just randomly blasting at the 8 cars in his immediate area.
Other than that, it seems pretty cool.