Monday, July 20, 2009

Protonaut Build 29: Finally, a Challenge

I've found that in programming Protonaut, I haven't been particularly challenged. That's not to say that it isn't super interesting or fun, but it feels that I've been largely coasting instead of actually thinking.

I'm not talking about Math problems - I'm absolutely pants when it comes Math in the first place, so anything calculated is a smaller hurdle for me. Rather, I'm thinking more of the mental excercises -I haven't had to do any serious figuring on how to do something or even constructed simple algorithms.

Until today, that is.

I started off the day right today by not getting to bed until around 5AM. Then I had a series of ludicrous dreams, then I was woken up at 6AM by the lady next door asking "Is this yours?" and pointing to a dead cat in a box she had brought over (it wasn't mine, thank goodness).

After a robust effort at continuing-to-sleep-till-noon, I thought perhaps today was a day to do something different.

Forgetting to eat, I scanned my to-do list and tackled the most interesting sounding task: Copying all items connected to whatever you clicked on. For example, if you created a complex molecule in Protonaut's editor, duplicating the whole shibang, maintaining proportions, and moving them around the screen all at once.

This one is a bit more complex than it sounds, as I did a really good job of keeping my level objects... well, more of a theory than actual hard definitions. My level objects suggest that an item might be in one place, and if you did some hefty math and lookups you'd see that it was correct. Bonds are an excellent example; they have no X,Y coordinates or size definitions - they are merely the idea that a bridge may exist between two already existing elements. All the hard definitions I allow the physics engine to handle for me. It's this exact architecture that's made it really quite easy to write up this whole deal.

I ended up making my first Linked List in years (through lack of requirement, not choice), and designed some tree-traversal algorithms to find out exactly what was connected to each other, taking care not to duplicate entries.

Then doing up the math to keep the X,Y coordinates offset correctly as I move them all around the screen... Well, let's just say it was a fun several hours worth of code. I feel like I've just had a fresh code shower. Ho ho!

Conclusion: Very satisfying.

So here it is, Build 29. Coming up on the big three-oh! Recent noteable changes:
  • Several sets of tutorial level revisions
  • Lots of minor glitch fixes
  • A dozen updates to player movement rates, gravity values, friction values, and scenario behaviours (eg: fixed the I'm-pressing-on-a-wall-and-can't-jump-high hard-to-reproduce glitch)
  • A dozen updates to the level editor (see them all here), including molecule copying and whole-molecule moving.

Sunday, July 19, 2009

How to make a Platformer Feel Right

One of the big draws to a platformer-style-game is the feel. A good, responsive control scheme with some nice animations can make the difference between sluggish boredom and excitement.

I've never really looked into the mechanics behind character movement before, and when confronted with the problem of making Protonaut feel nice, I had to do some research. As it happens, William and Sly was released that very day, and I took it a whirl.


William and Sly is an excellent game where you hop around in a tile-based world as a Fox named Sly. I highly recommend you give it a try! Sly controls very nicely. He is immediately responsive in his left/right motions, and jumping is a quick, rapid motion. On top of some fluid controls, Sly animates a sitting position while at rest, has a very nice run animation, and bounds in an animated arc when jumping.

One game that stood out for me as an excellent platformer was N Game (later remade as N+ for consoles). It was critically acclaimed for having excellent controls, so I revisited it to take a deeper analysis. You can play it here.

N Game was interesting to me. You play the role of a Ninja that simply has to collect some items and avoid the badguys. The left/right motion is a big sluggish - the player accelerates as he moves, but it feels OK. The jumping seems a bit unpredictable to me and I had a hard time navigating even the first level - but I'm sure it's just me not being used to it. It seems a lot of other people liked the game, and again - it was hailed for it's amazing controls.

What really stood out for me, though, were the animations. The player character had an animation for pretty much any situation he got himself into - sliding down a wall, various states of jumping, and even death. It really seemed to make up for it.

I had to take a look at a really crappy Flash game too, just to see what else was out there. Being a large fan of the Indiana Jones franchise, my eye was caught by an unlicensed ripoff named - well, indiana jones. I'm not sure if the loss of capitalization was intentional.

This game is definitely bottom-rung in terms of control. Just give it a quick run-through and jump off of a ledge and you'll see what I mean. It's almost as if you controls are mapped directly to the keyboard in a hideous 1:1 ratio - it's obvious there was not much thought put into this at all.

But the artistic team put a lot of polish onto this game, and there it is making money being front and center on the #1 platformer-oriented portion of the gaming portal. This kind of crap really gets on my nerves, because I believe the gameplay can (and should) stand on it's own two feet first, and have graphics applied later to taste. I said so just a few days ago. This game is the polar opposite - polish, lots and lots of polish, complete with unlicensed rips and cashing in on a brand I love - with no thought given to gameplay.

To help clear the taste out of my mouth I did a quick mental revisit to Super Mario Brothers (for a quick refresher, there's a badly done flash version - again, without licensing).

Mario had some fairly descent, polished graphics for it's time. The controls were crisp and responsive, and things flowed rather quickly. I'm sure I don't have to preach to the choir about this one.

I took all I had learned and compared it to Protonaut and where it was currently at (around Build 25 at the time). Protonaut was largely based on real physics. The player is average human density, average human height, and other game objects (like floors and platforms) were the density of concrete. Gravity was fixed to a steady 9.81 m/s^2, Earth norm. Each object interacted with one another with as-accurate-as-I-could-find coefficients of friction. Movement was handled by applying a steady force in a particular direction, capping off at a maximum speed. About the only unrealistic thing was how high you could jump, which seems to be a standard in any platformer ever made. An earlier form of the game wouldn't even let you change direction unless your feet were on the ground!

I figured real-life objects interacting in a real physics engine in a real-life environment would be a pretty good, fun experience, and would save me a lot of effort!

Nope.

Turns out people's natural rates of acceleration are... Well, boring. People can't stop running fast enough. People can't run fast enough. In short, people are sluggish, unresponsive creatures, and have no place in a fun platformer.

I ended up going through all my movement code. I increased the player's rate of acceleration, I made the at-rest-friction levels to be impossibly high to make him stop faster, I made his movement in the air more responsive, and made a whole bunch of number tweaks and if statements. (As an aside: The next time I make a platformer, I am not going to use a physics engine if I can avoid it! The amount of work that went into these tweaks was much higher than I wished, and I ended up breaking a few rules (resetting player velocity manually instead of applying a force, for example).)

I found the gameplay immediately improved and was a lot more fun. Playing a dorky, slow marshmallow of a man isn't as fun as a nimble ninja jumping from wall-to-wall. But something was still missing. It still felt like everything was moving in slow motion; nothing quite felt right.

I did another tour of the previously mentioned games and found out that none of them had the same problem. All 4 of the previously mentioned games felt "right" in a way Protonaut wasn't achieving. After some searching and feeling it out, I think I put my finger on it: Gravity.

9.81 m/s^2 is fine and dandy in our lives, but it feels a bit too slow and sluggish when you're talking about a world of superheros that can easily jump twice their height. With our incredibly poor acceleration rates and reaction times, a box could easily fall on our head and crush it. But the box doesn't fall particularly fast.

Cranking the gravity up to 13.5 m/s^2 made the game feel much more response and smooth feeling. I guess the whole idea behind platformers is to exaggerate everything; all forces should be somewhere around double of what they would be in real life. I'm still churning out new builds with new tweaks, but I'm finally homing in on what can be called "fun, invigorating" gameplay.

And for those that are wondering - yes, Protonaut's level editor allows you to define the gravity vector. I just altered the default setting and re-applied the gravity settings to the tutorial levels, and tuned the player controls for that environment... If you reset gravity back to 9.81, the player will jump higher than he did before.

Saturday, July 18, 2009

Protonaut Build 27: Gameplay Tweaks

After showcasing build 25 I got a lot of good responses. People are getting excited about the game, and I got some important feedback on the tutorial.

Changes in build 26/27:

- The tutorial is now split into 8 distinct parts. This allows people to get the "rush of victory" pretty frequently early on, while splitting new ideas into easy-to-process chunks.

- The tutorials now have descriptive text that tell people how to play each stage.

- The Atomic Detonator now has a bit more control. Hold down shift to increase power, release to launch. It's sensitive - maximum power is reached in only half a second. But it feels nice, and allows you to easily get things nearby with a quick tap. The A.D. will auto-launch when maximum strength is hit.

- Atomic Detonator's maximum power is now 25% greater (can fling it quite far now if you want to).

- Increased player friction while at rest to a much higher amount. It's now harder to slide down things (if they are shallow enough of an angle to get your feet on the surface) and when you let go of the movement keys you stop nearly instantly. This helps make the controls feel more responsive.

- Decreased player friction while moving, again making the controls feel more responsive.

- Replaced most of the tutorial text again in Build 27

- Fixed a bug where Nitrogen wouldn't explode when it killed you.

- Swapped default controls to the arrow keys (you can switch it back to WASD from the options menu)

- Fixed the immediate wall-jump bug when standing next to a wall and jumping straight up, making you appear to jump 2x the height of normal.

- Also, wall-jumping now requires that you are travelling away from the wall you are currently touching (should have been like that from the start...).

- If you have a downward velocity while wall-jumping, the jump will now "stall you" in place thus giving you a chance to recover. This fixes the dreadful "I'm walljumping like a madman but still falling down into this chasm" situation.

- Made tutorial text disappear upon victory/failure.

I'm getting pretty excited. I'm feeling like I've hit the end of my prototyping and I'm moving into full-scale production.

But since my prototyping was polishing itself along the way, it's more like I'm late beta and about to go gold. Great feeling!

Friday, July 17, 2009

Mechanics more than Gimmicks

I've often thought that the point, or the core concepts, of Protonaut have been lost because there is no good demonstration level - and all the levels submitted are by Fantastic-Contraptioners. It keeps the game looking like something it's not, so I decided to rectify that today.

But first, maybe I should talk about game mechanics vs. gimmicks.

Game Mechanics are the fundamental cores of gameplay. Mario is a platformer, and he squishes enemies by stomping on them. His various suits (fire flower, raccoon, etc.) offer up different mechanics you can play with, and they fundamentally change the game.

Gimmicks are the things that sound cool on paper, that look awesome, or are "neat" - but don't actually contribute to the gameplay in any meaningful sense. I like broadly lumping "realistic graphics" into this category. Sure it might look cool, and it might even sell a few extra copies based on game-footage and screenshots. But does it actually affect gameplay? No.

The thing is, it's really very easy to think up good gimmicky things. Camera tricks, dazzling explosions, distorting the image based on explosion shockwaves.. The list can go on and on. These are the low-hanging fruits of the feature tree.

I sat back today and thought about all the ideas I've been having. They're all largely gimmicky. I wanted the game to have a bit more meat to it - a bit more fun. Let the game stand on it's own two feet before I start swiveling cameras around. I think maybe I was overthinking the problem before, and I think I've hit upon a simple solution that fundamentally changes the game.

Previous to Build 24, all the round elements (Hydrogen, Oxygen, and Nitrogen) were identical except for the graphics. Now, Hydrogen is lighter-than-air and has the capacity to lift things; Nitrogen is dangerously unstable and can kill the player. Oxygen remains inert and simply rolls around.

The catch is - you still have to "collect" (destroy?) all three of them. If you let the Hydrogen float away from you, the level can become impossible. Nitrogen is tricky, as you can only set it off with your little flingalbe sticks (rods of ice? TNT? atomic detonators?).

Carbon and Aluminum still remain, of course - Aluminum being very heavy and capable of killing the player by falling upon him (and remains indestructable in and of itself), and Carbon provides a more utilitarian role as a "wheel" (that can be destroyed).

Before now, the game was largely about grabbing items in the correct order to prevent the collapsing structure from burying you (or the target elements). Though this might have a neat puzzly aspect to it, it is much better executed with a simple clicking interface. Running around on the structure was largely a chore and not exactly fun.

Now the levels can have all sorts of dynamics - a Hydrogen isotope floating a chain of explosive Nitrogen towards the player, for example. Puzzles triggered by lifts and dangerous rolling elements to dodge. Stacks of Aluminum to anchor and weigh things down. Levers, pullies, platforming fun!

Now, this is a lot to add to the game. Even though the amount of work behind it was marginal, the impact it has is grand. Now, more than ever, I needed a level that was easy - quick to play through - had a low risk of death/restart - and demonstrated all the core concepts of the game. And thus was birthed the first incarnation of the tutorial.

In the level I demonstrate how each of the elements work. What needs collecting and what isn't collectible. I introduce movement, jumping, and walljumping. There is a few places where you need to use the throwing stick to grab Nitrogen. I slowly introduce the concepts of bonds, and give a small sampling of different effects and puzzles that bonds can produce. I even demonstrate some unique properties (ie: structural bonds go through terrain), and top it all off with a "boss fight" of sorts.

I think I was successful in demonstrating that this game can stand on it's own two feet on the basis of elements alone. Using bonds is completely optional and you can actually have a fun, puzzle-y time without using them, and just focusing on the platforming aspect of the game. Level designers should be focusing more on the "wall" item, and get used to what you can accomplish from that level. Use bonds as a method of enhancement, not a focus of design.

A few other folks have stumbled upon some unique designs that speak to the essence of the game - Ryan Madsen for example, and a few others. I can't link to them now, as these changes have essentially ruined their designs. I never claimed to be an expert level designer, though, and I hope my level can inspire others to create even better ones.

I am a very happy guy right now.

Walking Away

Today I learned to walk away from a feature that was bugging me.

Stupid features.

First of all, updates have been slow in the last month because:
  • There is a plethora of sunshine and nice weather
  • SimCity4 got reinstalled on my computer
  • The Secret Of Monkey Island: Special Edition came out on Steam
  • ArmA2 came out, which is wicked fun (helicopters!) and has a scripting language (map editing!) so I've been getting my code fix through there
But above all of those, it's mostly been because this one particular feature had been really nagging at me. It's simple on the surface: Whichever way gravity points, direct that to be "down" on the Protonaut game screen.

As I chugged away at it, I started running into more and more problems. Lining the camera up with the player, keeping the player himself oriented correctly, orienting the player's bounding boxes, adjusting all the in-game vectors (throwing TNT "up" isn't so easy any more, and all the movement keys need re-working).

It was getting more and more difficult, and the more I dug at it the more often small "gotchas" would spring up. It really started to get on my nerves, and I was having a lot of trouble staying focused on the whole project because of it.

Tonight as I lay in bed around 1AM, I couldn't stop thinking about it. I decided to get up and do something about it. I spent an hour or two looking at all the code, taking stock of all the work - and then took a step back and said, "wait a minute."

"Is this feature even any good? Will it improve gameplay at all?"

I couldn't wrangle a "yes" out of that. It's a feature that's kind of neat on a technology scale, but as many things as it would make "cool", it would make other things impossible. For example, a few people have made levels where you are "on a train" that is colliding with the wall at a rapid speed. I don't have any moving parts in the game though - the movement is simply the gravity vector pointing a little more sideways than is normal, and the "train" is actually just "falling" downhill. If I rotate the screen to match gravity - it ruins the illusion and makes the control mechanism (hopping around on the train while it moves) impossible.

I was thinking I'd eventually have switches in-game, that would allow you to rotate gravity at will. Again, kind of neat - but I don't think it really fits this game too well.

So I walked away from the feature. I gave it two big middle fingers as I reverted back to an earlier fork.

In the hour since that reversion, I made a dozen changes and added some new features, uploaded a new version to the site, and made a few blog/forum posts about it.

I've gotten more done in the last hour than I have in the last month.

Anyway, build 24 is live on the Protonaut site if you want to check it out. New stuff in a nutshell:
  • The level editor now has cursors that indicate the current drawing mode.
  • TNT has been pretty much transformed into something not-TNT-like. It still asplodes, but with hardly enough force to move an ant. I might make them simply "fade out" eventually instead of exploding. It detonates after 5 seconds.
  • Nitrogen (as everyone knows) is unstable and will explode upon touch (in the fictitional microbial world of Protonaut, based on authentic Xiuuzn Universe Physics and Chemistry). I think this might be a big key to more-fun-gameplay, as it adds a direct-death challenge to the player.
  • Nitrogen still has to be collected/destroyed, though, so just hopping over them all won't work...
  • But "TNT" (or whatever it is now) can set off the Nitrogen for you. :) Hucking things around is now a required game mechanic! (if there is nitrogen in a given level, that is)
  • Some display glitches resolved, level name now appears, and included some network error catching for level loading.

Friday, July 3, 2009

Still Working!

Nope, the project isn't dying. Just having some technical problems on the code end.

For the last week I've been off-and-on struggling with how to best handle the "camera" of the game. Some (currently unpublished) changes to the gameplay have made some more dramatic alterations to the camera a requirement - I'm struggling with both selecting the optimal strategy, and executing it.

Once I settle on something it'll roll out fast enough.

It looks like I'll be attending GDC Austin in September! Colin got a speaking gig at the Indie Games Track which is really cool. There's a strong Fantastic Contraption following out there so I'm going to see about having a quick meet and greet or something.