Monday, September 13, 2010
Super Mario's 25th anniversary! He's looking kinda old for 25 though... and dirty
Excuses for a later post. I had this little birthday last Saturday (no, not from Mario). With as a result that I couldn’t come any further than the sofa all Sunday, watching cartoons. Talking about sofas, I made one last week, see the screenshots. Other than that, I was busy with light flickering schemes and controls this week.
Light flicker schemes? Sounds more difficult than it is. Maybe Wolfenstein not yet, but Doom 1 already had the option to let a light flicker on a certain interval. You know, buzzing TL bulbs. Lights are a little bit more complicated these days though, but the idea remains the same. Compose a record of "random" values that tell how often, how strong and at which frequency the lighting changes. Continuously buzzing? Slow & steady on/off maybe? Light up with peeks sometimes? For each light, you can choose a schedule (normal, buzz, disco, rotating (sirens), etc) and fill in some random values. Scripts can also change this schedule setting. For example, when shooting a light you can select a schedule where the light flicker/sparks sometimes.
Ok next issue. Controls. I never understood all the fuzz on controls in game reviews. "Superb controls!"... Except with platform games maybe, I always took that for granted. But making your character move smoothly and gently taking the stairs is harder than it seems. Not only the physics, also handling the input on a smooth matter can get tricky when running at lower/fluctuating framerates. Losing control over your character is one of the most frustrating things that can happen in a game. Don’t want H@x0r or FunkySn!per1987 getting fragged in a Deathmatch game because of the sucking controls.
I had to smooth the mouse-look to start with. Certainly because recording that movie requires a smooth camera look as well of course. But it would move a little bit jerky, probably due the lower framerate. So I moved the mouse handling code to another background thread to get updates on a high, fixed interval. Easy right? Well, not really. I tried billion different filters, averaging, acceleration and damping before it would run a little bit. Now it looks like this:
------------- how the hell do you insert code blocks in Blogspot? ------------------
< thread makes about 200 samples per second.
getMousePos( point ); // Windows API call
deltaX += previousMouseX – point.x;
deltaY += previousMouseY – point.y;
if ( ++sampleCount == 2 )
rotationX = deltaX * _mouseSensitivty.X + rotationX * _dampingFactor ;
rotationY = deltaY * _mouseSensitivty.Y + rotationY * _dampingFactor ;
playerCamera.applyRotation( rotationX, rotationY );
deltaX = deltaY = 0; // Reset delta
sampleCount = 0;
// Centrate cursor
setMousePos( screenW/2, screenH/2 );
// And if you saw errors, yes that could be true as I'm writing Turbo Pascal actually
------------- EndOfCrap ------------------
Still not nice, but at least it improved. Have to make a shooting range for testing the mouse some day.
All right, furthermore a couple of basic moves were still missing. Sprinting and strafing. In most FPS games the player runs a 20 hour marathon at lightspeed. My game is somewhat slow-paced though, so I swapped it for fatguy controls that make you sweat after 20 meters. By default, the player just walks. When holding the shift button, the player starts "jogging". And when quickly tapping the shift, that lazy bastard finally starts to sprint… if the stamina bar didn’t reach zero. Pretty much the same way walking works in Grand Theft Auto games.
I bet your family will throw you and your computer out after banging the shift button for 10 minutes, but don't worry. You only sprint when shit hits the fan. Which shouldn't be too often. While sprinting you can't aim guns or make very sharp turns for example. Plus all the noise will attract enemies. On top, as you get more tired, aiming, vision, hearing and everything else will get distorted. One of the tactics in this game is to keep your heartbeat down. Stay cool dude.
We're still far from done with the controls. Lot's to improve when it comes to physics and stair walking(falling) for example. But that's for another time.
Got my chamber filled with the IKEA Hökebünker set