Tuesday, March 9, 2010

Happiness is a procedurally generated explosion


Arrow keys for movement and crouching, spacebar to jump. Use arrow keys while swinging to increase his spin. Hold down spacebar to make the jump last longer. Hit spacebar again when holding on to a wall to wall jump. A is for punch and D for kick. Press S to hold a grenade, the release S to throw it (be careful - hold it too much and you'll blow up!


Dreg goes Boom now!

Well, sort of - he throws grenades! To make it work, hold S start holding a grenade, then release S to throw it (I did it this way so that you can hold a grenade and wait until just before it explodes to throw it at an unsuspecting enemy who won't have time to run away). Or you could simply not release S then get blown up. As you wish.

This was a big ol' undertaking! It required a bit of work everywhere - I needed to make the grenades respond to the gravity shifts, and seeing as I'd been a bit stupid this meant fiddling around with things that I'd done badly, but hey, I'm used to that by now.

So yeah, it meant working on collision and physics for the grenade, on computer AI to make the thugs run away, on graphics for the explosions, on level set-up to have walls that can be blown away and on player input.

To give the player a decent amount of control over how Dreg throws grenades, I decided to have the arrow keys dictate a fair amount of how the grenade is thrown, as well as Dreg's movement at the time of the throw. Notice that if you throw the grenade while Dreg is crouched, he'll just drop it in front of him.

It also caused unexpected headaches, more on which later!

Anyway, I now have all the major items for Dreg to find within the game. By major item I mean those things that allow him to access new areas. At the beginning of the game, Dreg will have no objects and will only be able to wall jump once at a time. As he progresses he'll get these (probably in this order):

- triple wall jump
- whip (can latch on to poles and damage enemies - can be upgraded)
- double jump
- grenades (deadly against enemies, and smash through weak walls to reveal new areas)

If the list seems a little small, bare in mind this is only the beginning - I think I mentioned in an earlier post that I want to make a couple of "chapters" for Dreg. This is nice because it justifies all this work on the game engine (if more than one game will come of it), and it allows me to make the aims for the first game more realistic. In later games I can have additions like guns, grappling hooks, instant transportation devices etc.

Also, there'll be other items to get, such as better armor and offensive stuff (but focusing on unarmed combat). There'll also be stuff like the ability to have unlimited wall jump, but it won't be vital to complete the game.

It all feels so close now! we might see this game completed yet!

Anyway, if you're interested in the nitty-gritty of the grenade-a-thon of last week, read on!

< geekanisation >

So the reason I had to do a lot of fiddling is that I had foolishly focused on the Character class (Dreg and the thugs are extended from Character) when a lot of the functionality (such as collision detection and resolution) should have been in the parent class, MovingObject. Grenades, obviously, are moving objects, but not characters. So that was boring

But the really weird problem was the issue I had with having Dreg hold the grenade in his hand before throwing it. I thought this would be necessary to give the player control over when the grenade blows up after being thrown, but the issue was that I wanted the grenade visible before it got thrown.

I obviously didn't want to animate a run, jump, skid etc. cycle for Dreg with him holding a grenade, so I thought I could simply add an image of a grenade to Dreg's hand and be done with it.

The issue is that Dreg and his various components are scaled to different degrees, and the grenade would fiendishly change shape depending on what animation loop Dreg was in. I had a problem: I needed to have the grenade appear behind his hand, at the same position and rotation as the hand, but maintaining the grenade's original scale.

The solution involved a hell of a lot more involvement with transformation matrices than I would ever have liked to experience. That said, I feel super smart now.

Easiest of all, surprisingly enough, were the explosions. I had a clear idea of what I wanted, and it worked pretty quickly!

The most annoying part was making the map screen aware of walls being blasted away. It was all very hacky. At least it seems to work now!

< geekanisation />

1 comment:

  1. I love the explosion. Just love it! Great job! I'm going to put my comments in flash kit in a bit. Check there.

    Xen Element

    ReplyDelete