Showing posts with label collision. Show all posts
Showing posts with label collision. Show all posts

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 />

Saturday, November 14, 2009

Collision revisited... again... please may it be for the last time!


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. Try to make the collision detection fail!

If you want to check out the combat go here



Today's been a good day. I like it when I figure out solutions to long standing problems. Do you remember a while ago when I did a whole update about the bugs I'd fixed? Well this is more of the same, really.

I'm sure you've all noticed that I've always had floors sort of overshoot the walls they're over. This was due to several reasons, all of which would have Dreg happily drop through a floor/wall into oblivion. This is not good for gameplay.

I'd resigned myself to the fact that I would I'd have to make the floor extend beyond the wall whenever designing levels.

But then I noticed some other problems. If Dreg jumps just high enough to be above the wall, but not quite high enough to land on the floor above, this happens:


oh noooooooooooooo!


Yeah, that sucks. You can try to do it on the previous post - it's not so difficult once you realise it's there.

Also, You can very easily fall through the geometry of the little podium at the end. As I said before, I'd simply decided that this would be a limitation of the game engine, so I couldn't have that kind of geometry.


Dreg and the podium are one


But today, as I said, was a good day. My brain was working even better than usual, and I though up a solution. Well, specifically it was to solve the problem presented in the first picture, but the solution was so simple and effective, I realised I could extend it to everything, and it would even work for the podium!

Then I did more stuff to deal with all the little problems I knew existed. Somehow the programming muse was on my side today, and I sorted them out. What a good day it's been!

This is a much bigger deal than you might think. I means I've suddenly liberated myself from constraints while designing my levels. I can have the geometry all over the place and not have to worry about the issues from before. It's amaaaaazing. Did I mention this is a good day?

So I quickly cooked up the level you see above, and it shows all the sorts of things that couldn't be done before, but now can. You'll see there's still some overlap at the corners, but this is done automatically - in the level editor I just have the lines meet each other (of course, don't forget that in the final game you won't be seeing any of these lines - just beautiful, beautiful backgrounds, yeah?).

Play around with it - I'm pretty sure the collision detection doesn't fail, though obviously if it does for you, pleeeeaaaaase tell me!

Wednesday, October 14, 2009

Variety is the spice of fight


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 and D to attack.

See below for a list of Dreg's fight moves.



Wahey!

Well, for those of you who come regularly, I'm afraid there's nothing new gameplay wise for you to enjoy. I've been working on an essentially aesthetic thing... the thugs are all different now!

I've taken advantage of the ability to play around with movie clips to give each thug his own look. It's all rather simple, really, but the problem was that I had set up the characters awkwardly, and I spent a lot of my time going through the thug movieclip and fixing it (namely, replacing graphic symbols with MovieClips). It was slow, dull and annoying. Now I have to do it with Dreg too, argh!

But at least what this means is that in the future I can make a character, then whenever an instance of that character is created he'll be a little different to the other instances, making the game feel that tiny bit more varied and organic.

I've also made them slightly different sizes, to add to the fun!

It also means that as the player buys new items for Dreg, they can alter his appearance, making everything very cool.

This is also an opportunity for you to immortalize yourself on the rankings page. For those of you who are new to this, these are the fighting moves:

punch him in the face lots:
A + A + A

kick'im:
D

upper-cut:
DOWN + A

get his ankles:
DOWN + D

dirty my trousers:
D while running

flying kick:
D while jumping

kick 'im onto 'is butt (more powerful kick with ever-so-slightly different animation):
A + A + D
OR
DOWN + A + D (this one is fun - you fling him into the air then kick him off into the distance)

Sort of roll over backwards then then kick him in a sensitive place, thereby flinging him away:
A OR D while moving into him

No, look over there!
move into him and press A while he's facing away from you

slingshot! (my favourite):
Run towards him and press A just as you get to him

Double dragon rip-off:
DOWN, release DOWN and press D while rising.

Wednesday, October 7, 2009

Tweakage galore!


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.

If you haven't already tried it and want to know what the combat is like, go to this post.



"Hey Awoogamuffin!" I hear you cry, "What's the big deal? You haven't changed anything! You're so boring and unsexy!"

Well, I won't lower myself to your frankly insulting level, but I'll happily dignify your uncalled-for comment with an explanation.

And anyway, I still haven't received any proof that any of you have found the secret room. There's nothing in the room. But it's secret. Go find it.

Though it may not seem that anything has changed, the collision detection has undergone a revamp. The version in the previous post was plagued with lots of bugs - Dreg often would get stuck to walls, and worst of all, in several places he could actually drift right through them!

Here are a couple of examples:


This one is relatively easy to replicate - if you jump as if you're going to grab the ledge of the bottom cube just as the top one is moving towards you, this happens. It's horrible.



This one is more difficult to replicate - you have to jump just as the block is coming down on you and it'll push you through the floor. The line underneath was to "catch" this happening, and though it works (more or less) it annoyed me that it was necessary


There were also plenty of plenty of places where Dreg would get "squished" for no apparent reason, other places where he would fall through the geometry and the whole thing was generally plagued with nonsense. But now it's all fixed! I'll go into a longer explanation later in the geek section...

I've also made a few visual changes - giving the platforms a foreground element so that Dreg can get hidden behind rails or walls that are facing away from the camera. It looks a lot better when Dreg gets squished now because he's half-obscured by the right-hand block.

I also made it so that it doesn't look stupid if you roll off an edge (down + jump to roll).

So now the geekiness!

< geekment >

So yeah, I realised what was happening with the first bug picture I showed was that when the collision detection saw that dreg was in position to grab the ledge, the game would simply teleport Dreg straight to the ledge. This would sometimes teleport him right through a wall!

Now even though I knew that to keep collision detection functional you should never directly modify the x and y values, I had been doing that regardless because I'm lazy and a little stupid. Anyway, I wrote a function that would perform a new collision detection test before placing Dreg on the ledge (I had to do clever things to avoid the wall underneath the ledge counting), and it worked!

This was when I thought I should comb through the whole game and make sure that the x and y values are only ever directly changed once all the collision detection has been completed, which meant performing additional checks whenever Dreg ran into a wall, landed on the floor or hit a ceiling. Now Dreg never gets teleported anywhere unless I want him to!

I also completely re-wrote the stuff that handled Dreg's interaction with moving floors and walls to avoid the stickiness I mentioned earlier.

In any case, the lesson learned is that with collision detection, you can't cut corners - every time you want to move a character, check whether there's nothing blocking him first. Tralaaaa!

</ geekment >

Monday, October 5, 2009

It's squishtastic!


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.


Yay! More stuff!

Well I've considerably worked on the whole moving platforms thing, the best bit being the implementation of squish mechanics (that's the technical term) so that Dreg can be crushed and squeezed to your delight. It also allows for some fun pseudo-puzzle acrobatics which test your block negotiation skills (also a technical term).

It's still a little buggy in places - sometimes Dreg grabs onto a ledge when he shouldn't, and there's the occasional odd sticking to walls. I've uploaded it anyway because I need more attention!

I'm certain there are plenty more bugs. That's where you, my play-testing monkeys, come in - I want to hear all of the weird bugs and quirks you find, and I'll do my best to fix them!

This has got me really excited about the possibilities for level design. This little demo is only scratching the surface - I can make the moving lines be at any angle, and travel along a path of my choosing (I've even half-coded something that would allow me to use the paths within Flash to create paths for my platforms).

The nice thing about this being a science-fiction world, and a 2D computer game, is that I can get away with crazy level design, involving huge moving parts and whatnot (I'm toying with the idea of a giant robot, trapped and spanning across various gravity zones and feeling generally unhappy with the world).

So can you navigate Dreg through the fun? There's also a little "secret" room (not much of a secret now that you know about it) of which I hope the game will have plenty!

Tell me what you think!

Monday, September 28, 2009

transportational joy


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.


I have moving platforms!

This is still just a simple demo of new stuff. If you want something more involved, and haven't done it yet, go fight some thugs and upload your high score here.

Yeah, they're glorified collision lines that have velocity. I had to do a lot of fiddling to get everything working just right, but I'm happy with the final result.

I was going simply to have a platform helping you get across the pit, but that would be too boring, so I've given you a very simple puzzle - can you get to the other side? a brain teaser that should take you all of two minutes to figure out! Fun fun fun!

So, the nice things about what I've done in these last two posts is that there are multiple uses for each - the line that kills Dreg then resets him could also be used to avoid game-breaking bugs. If for dodgy collision code or dodgy level layout Dreg falls through the floor, I could have a sort of "safety net" that will put him back where he should be...

As for the moving platforms, they could also be things like floating objects, or cars, or whatever, to keep the level layout interesting.

So what's next? Well I still need to integrate moving platforms into the level editor, as well as design different kinds (those that move in loops, those that are only activated when Dreg jumps on them, etc.)

After that, here's my "to do" list:

- menu screens
- NPC interaction
- the HUD
- items
- cut scenes
- stitching zones together (as in, the whole game can be explored freely, but to avoid too many demands on the processor, the world will be split into zones that are loaded as the player enters them...)
- level design - how are events triggered? how are missions given and stored?
- potentially other acrobatics (monkey bars, ladders etc.) but I'm not sure I can be bothered with them

Once I've got all these engine elements together I'll be able to get down and busy with making the actual game - designing, animating and maybe doing some extra coding for enemies, designing levels etc.

The plan is to have the whole game done before Christmas. Excitement.

Thursday, July 30, 2009

straddling is fun


Arrow keys for movement, 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. Click on the game to start interacting with it


Yeah, so gravity shifts are obviously out of this world and wonderful and I can be incredibly proud of myself. That said, in the previous post, one crappy bit was the nonsense that would happen around gravity rifts - I went a little crazy with crossing over collision lines and other such nonsense to keep Dreg from losing his cool and shifting into an alternative reality.

As I mentioned in the previous post, I wanted to create special collision lines that straddle multiple gravity fields, including floors which Dreg could run along without the collision detection giving up and stomping off in a huff as soon as he hit a gravity rift. This meant making funky collision lines that would return different values depending on which gravity zone Dreg was in. I also had to integrate it all into the chaos that is my "level-editor".

Hopefully the rather non-fun demo at the top of this post should demonstrate that it works!

The exercise also allowed me to do lots of tweaking on the collision detection itself, and Dreg is now even less likely to casually walk through walls, though I wouldn't like to claim it's impossible. I've tried to minimise the need to limit the actual level design possiblities, but there are a couple of things I have to keep in mind- if I try to make a floor behave as a wall it gets upset with me.

That aside, I now feel I have a system which is flexible enough for me to make the kind of levels I want to make, so look out for the next post - it's going to be fantastic.

I'm sure you, my avid fans, were a bit upset about how long it took me to get this update up and running. The reason? Well, this project was my topmost priority for a week, and I was seriously riding a wave of enthusiasm. The enthusiasm has dissipated a little, so now it's a case of trying to maintain a certain level of discipline and making sure that I keep on working. My having finally started playing GTA4 hasn't helped either.

Oh and I've finally caved in and made Dreg move with the arrow keys!

Saturday, July 18, 2009

First update of the game!


press A and D to run, and spacebar to jump.


WARNING: I’m going to talk about my plans for the project, making references to other games, so if you’re not a gamer (which is probably most of the people reading this) you might not know what I’m talking about. I guess at least wikipedia is there to fill in gaping holes in your gaming knowledge, which obviously you want to fill.

As usual, I’ve decided that the best approach to making the game of my dreams is to be as stupidly unrealistic as possible, and see how far I get. So I’ll talk about my ideal game, though I doubt I’ll get anywhere near it…

Acrobatics: I want to have the acrobatics of the newer Prince of Persia games, complete with wall-jumping, pole swinging etc. but with the added fun of gravity shifts! This is what I’ll start with, so in further detail for this to work I need:

- responsive controls: unlike the first Prince of Persia, this game won’t make sacrifices in control for the sake of protracted animation. I’ll try to keep responses fast, with the jumping feeling more like Mario than Another World.

- Flexible collision detection: The platforms won’t be Axis Aligned Bounding Boxes, but instead line segments of any angle. The angle of the segment relative to local gravity will dictate whether the segment is a ceiling, wall or floor.

- Gravity shifts: I’m hoping I can make this work by simply having all the game mechanics rotate between each zone.

Fighting: I’d like something approaching the fluidity and depth of Bungie’s Oni (an underappreciated game in my opinion). I want to encourage the player to vary his/her style by having enemies increase their ability to block a certain type of attack each time the player uses it. It makes sense in my head, ok? More details when I get to it.

Story: I imagine progression in the game to be like Zelda – relatively controlled, but rewarding exploration. Just like Zelda (or Metroid), as the player progresses they’ll get more objects/abilities allowing them to access new areas in parts of the world they’ve already been in. So a player could just plough through the game’s main story in a relatively short time, or spend time exploring for extras and secrets. Oh, and I also want boss battles.

Anyway, I’ve been working on this game for three days, and thanks to my aborted earlier efforts at making games, progress has been surprisingly fast. I’ve already got most of my first two goals regarding acrobatics done, with gravity shifts hopefully coming soon.

My previous game involved space ships, which was bad for several reasons. A lot of casual gamers have real problems grasping the press-right-or-left-to-turn-and-forward-to-thrust way of controlling things, and also a space ship has considerably less personality than, well, a person.
With Dreg I already know the guy from previous projects, and it also allows me to flex my animation muscles. Throughout my life I’ve been ok at several disciplines (music, drawing / animation, programming, story-telling, programming) but not excellent at any of them. Computer games allows me to bring these skills together and hopefully get a whole greater than the sum of its parts.

Anyway, at the top of this post is the game so far: A and D control movement, and SPACEBAR is to jump. You can wall-jump by jumping against a wall, then pressing spacebar again to jump off it.