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 >

2 comments:

  1. Hi,
    nice preview so far, I was wondering if you were interested in making game more or would like help developing your game. I run a company that makes flash games and we mainly work with multiplayer games.

    Let me kno :)

    ReplyDelete
  2. Nice, seems the walking over the blocks problem is fixed, and also the other problem when going up after grabbing a ledge...

    ReplyDelete