Staging Code Tasks on Notepad

I’ve tried dozens of organization apps and software, and Notepad is still my favorite.  Its biggest drawback used to be accessibility–having to keep the text files with you if you work on more than one computer.  DropBox fixed that.

I tend to keep a text file of tasks so I know where to pick up tomorrow.  It’s vital that one of those tasks is immediately accessible and not too abstract.

  • OK: “Fix overlapping blocks collision bug.”  
  • Better: “Reproduce overlapping blocks bug by building a test room.”

Today was one of those coding days where every fix reveals yet another fix that’s needed.  My initial task list was about 15 items but I probably checked in over 40 changes today.  It’s frustrating to have done so much more work than I thought was needed, and still not be where I thought I would be today.  But, I’m still generally on track, and things had moved forward a lot.  It could be worse, I could have attempted a major refactoring and broken things so badly that I had no choice but to revert to the last update in source control.  It’s happened, but not today.  Today was just a steady unraveling of long-dormant bugs and tiny features that insisted on their existence at the last minute.

Notepad kept me sane.  Minor bugs kept cropping up, and I would just jot them into the text file.  As I fixed them, I would cut them out and paste them into the source control check-in log.  I’m down to about 3 right now, nothing major, and if I weren’t superstitious about this sort of thing I would say I’ve totally got it handled tomorrow.

 

Yes, Another Writing Book-Related Post

Yet another awesome Kindle book, Robert’s Rules of Writing, has given me this:

RULE 16. Write What You Read.

Basically, look at your bookshelf and your bedside table.  This is the type of stuff you know best, love best, and can write best.

If you look at my game library, the only puzzle platformers you’ll find are Braid and Limbo.  No wonder Escape Goat is taking way longer than I expected to finsh.

Squish Detection in Platformers

Top: Direct hit, kill. Bottom: Gentle nudge out of the way.

I’m amped.  I started writing a post on game production and teamwork versus working solo, but it’s just not something I can do tonight–draft saved.  Right now I just have to celebrate the squashing of an ancient, pernicious demon bug from hell in the Escape Goat code.  Could it even be called a bug?  It never even revealed itself in that mortal form.  It stayed for weeks, months even, as the Feature that Wouldn’t Be.

It was creature squish detection.

Here’s the situation in a nutshell:  If a block falls on you, or you get mashed between two moving walls, you get squished and have to restart the room.  Makes sense.  And detecting this is easy enough: if after resolving all collisions (clipping creatures to the edges of walls) a creature is still intersecting with a wall, you’ve got a squish happening.  That means one wall clipped the creature into another wall and it can’t be pushed away.

There was a problem with this.

Getting squished by a single pixel of falling block was annoying.  So was getting crushed when you were only barely inside a moving wall.  Come on, that should just nudge you out of the way… it’s barely grazing the goat’s tail!  You can’t make me restart this whole puzzle for that.

But… I also can’t take out squishing.  What if you get crushed by a block, do you just get to clip through the top of the block?  Or through the floor below?  That’s no good.  Squishing machines are a great hazard device in this game.  I’m not giving that up.  There has to be a balance… you need to be able to tolerate a few pixels of squishing and “nudge” the player out of the way in those situations.

I tried about 5 different methods of handling this.  And just a couple hours ago, after intense frustration and perseverance, I found the solution:

  1. Do all clipping of creatures to walls and world obstacles
  2. If any creatures are still intersecting with walls, start a crush timer on that creature, which lasts for 5 frames
  3. If the crush timer reaches 0, kill the creature.  (It took too many frames to resolve it to a safe position.)
  4. If the creature is not intersecting, store its position as a “safe position”
  5. If the creature is no longer intersecting, reset the crush timer, and compare its new position to the safe position that was stored before.  If the distance is greater than the squish tolerance (I set it to 5 pixels in either axis), kill the creature.

Essentially, give the game 5 frames to resolve a safe position for the creature after being crushed.  If this new position is too far from the start position, well, I can only be so forgiving.

Top: Direct hit, kill. Bottom: Gentle nudge out of the way.

When you face a feature from hell, stick with it, draw pictures, and try solving it from a variety of angles.  You’ll get it eventually and it’ll feel great.