Saturday, December 31, 2011

Kart Racer- Quick Improvments

Over a few days, I've made a few quick improvements.

First, the aesthetics. I've designed a conceptual HUD [heads up display] for the game, including the race position the player is in, a timer, and "Get Ready..." and "Go!" text that displays as the race starts. However, the race position and timer are just placeholders- static text that doesn't change. This way you're always in first. Not much of an accomplishment seeing as the AI insists on turning left all the time.














Also, a few technical improvements- the first being that I finally added an invisible wall around the island in SawShark Beach. This prevents the karts from driving... on water. Guess I never really got around to kart water physics.

Next, I've changed the way to control the kart's speed. Before, I simply capped the kart's velocity when driving. I also lowered it when the kart went off-road. For example:

car.linVelocityMax = 65.0
    if road.positive == False:
        car.linVelocityMax = 40.0

Unfortunately, this method proved to be clunky, as the kart suddenly slowed down when driving into grass or sand. I needed to make the speed transition more natural. So I came up with this instead:

elif gas.positive == True:
       
        if (carspeed.y >= 65.0) and (road.positive):
            power = 0.0
           
        elif (carspeed.y >= 40.0) and (road.positive == False):
            power = 0.0
           
        else:
            power = -gasPower

This will change the kart's engine power [gasPower in the script] according to certain conditions. Once the kart has reached a velocity of 65 on road, the engine power will be set to zero until the car slows back down. It does the same when off road, but sets it to a lower speed. This effectively caps the top speed, and makes the slowdown feel natural when driving into grass. It will also make designing the mechanics of the boost power-up much easier. 

That's it for now. Still working on that artificial intelligence.

No comments:

Post a Comment