Sunday, December 17, 2017

Half-height collisions

I'm back at the metroidvania game tonight. I had just gotten collisions mostly working, at block sizes of 16x16 pixels.  But the artist I'm working with (the amazing Frankengraphics) asked if we could do it at half-height -- so 16x8 pixel collision resolution.

One thing I've learned in life is to try to say yes to every feature the artist recommends. It will make your game better (which is why the original Anguna turned out so well: Chris had tons of great artistic suggestions, which required me to completely rewrite the engine after he came on board!) 

In this case, I reserved 1 byte of data for each metatile of 4 16x16 blocks, which means 2 bits per block. That could allow 4 different collisions types: open, blocked, destructable, and "special" where special depended on the room (with options being things like lava, water, etc). To add half-height collisions, something was going to have to change. But I didn't want to re-tool the whole engine to support EVERYTHING operating at a 16x8 level.

So the answer I settled on (for now, at least...we'll see how it works) is that I'll add an extra byte of collision data per metatile, meaning each block gets 4 bits, which is 16 different collision types. One of those collision types is half-high-blocked.  So I check for that separately in my collision routines, but everything else (block destruction, etc) can still operate at the 16x16 pixel level, which should make everything easier.

We'll see if that holds true....

It's hard to really tell, but the big block that the vehicle is
sitting on near the top-left is 32 pixels wide, and 24 pixels high.  Meaning the top
layer is 2 half-high-collisions.

No comments:

Robo-Ninja Climb 2600

So I had this crazy idea. The game logic of Robo-Ninja Climb is really simple. And so is the display. So in theory, with the NES and the A...