It didn’t come without troubles though. I thought working with pixel art would be easy. Not quite… there are some gotchas…
Originally, I wasn’t sure what the art in Vox Venio was going to be like. That would depend on the artist. So I engineered the game to work with variable, possibly huge, sprites.
It turns out that Vox Venio’s artist — Candice — specialises in (quite charming) pixel art. “Great,” thought the lazy programmer inside me, “if they could do pixel art games back in NES days then I should have a good shot at it with modern tools.”
With great enthusiasm I loaded some of Candice’s in-game sprites, such as our hero:
Goodbye placeholder Mario!
But whenever the poor chap moved he started vibrating like he was shivering in the cold Martian air. It was especially obvious when he jumped, as there’s no jumping animation… A stiff, standing man vibrating through the air is quite obviously not right.
After a bit of hunting I found where I went wrong. I was using a overload of Draw that took a Rectangle — an integer-cornered thing — as a guide of where to draw. So instead of moving smoothly along, the sprite would snap along pixel-by-pixel. Combine this with a smooth-tracking camera (I can do some things right) and hence the “vibration”! A quick change to using a Vector2 and all was well.
I still need to tweak the animation code. Instead of “centering” on the sprite’s head as in the animation above, my code is focusing somewhere arbitrary and less precise, making the gait look wobbly and drunken.
In keeping with my original plans to prepare for sprites either large or small, the game’s logical resolution (i.e. the resolution it uses for all its calculations) is set to 720p. That, however, requires Candice to draw pixel art three times larger than strictly required.
I could quite easily reduce the logical resolution to, say, 320 x 240. That would remove the necessity of artificially enlarged sprites. That doesn’t mean players are going to have to squint to play — I’ve got code to resize the game to any physical resolution and it works quite well if I do say so myself (except when it eats the background texture when approaching 1080p… but that’s TODO).
Point vs Linear Sampling
What I’m more worried about is point vs linear sampling. Unless your resolution is a perfect multiple of whatever logical resolution I choose, there can’t be an easy resize from logical to physical. Pixels will die along the way.
Point sampling (left). Linear sampling (right).
Linear sampling “blurs” what it draws, so missing pixels aren’t so noticable. But that blur kind-of spoils the pixel-art appeal. Point sampling keeps things crisp, but when pixels are missing they’re more noticable.
There’s no easy answer so I’ll probably just let the user choose in the options menu.
You can read all Vox Venio updates here.