Large Multi-Sprite Enemies
May 29, 2018
Pixel Vision 8, like many of the original 8-bit game systems it is based on, can display 8x8 pixel sprites. While this is good for some game objects, most enemies will need to be made up of multiple sprites. Complex enemies may even need to use as many sprites as the display can handle. In the case of the Nintendo, it could only draw 64 sprites on the screen at one time. Let's take a quick look at an example of a complex enemy in Zelda II and how they worked around the limitation of drawing sprites to the screen.

As you can see, Link is fighting Rebonack from the Island Palace. The knight and the horse are actually made up of multiple sprites, just like Link, but the developers of Zelda II used some neat tricks to pull this off on the Nintendo's limited hardware.

First off, we can see how the knight is a combination of multiple sprites when it gets close to the edge of the screen. If you remember back to my post on overscan, you can see that sprites are removed when they cross the left border of the screen to keep them from wrapping around to the opposite side. The other thing you'll notice in this battle is that the level isn't scrolling and there are no other sprites on the screen. This gives the enemy the full amount of sprites the Nes can display after taking into account Link's animations.

When the knight comes off the horse, you can actually see the 2nd knight for a split second get drawn to the screen, before it is removed from the horse. This is another neat trick since there wasn't enough memory to store all the animations it would take to show the knight getting off the horse. This way they could quickly switch between the mounted knight and the standing knight when Link knocks him off.

This also illustrates that the knight's top half is shared between the riding and standing animations, another clever way to save sprite memory. The other ways they saved memory was to animate the motion of the horse programmatically. They also compost the knight on top of the horse as it moves. This is only apparent at the far edges when it tries to turn around but gets cropped by the screen's edge.

In Pixel Vision 8, there are multiple ways to draw larger groups of sprites on the screen. You can leverage DrawSprites() or DrawSpriteBlock(). Each API has a specific use case depending on how you have your sprites arranged in memory. There are two built-in demos that illustrate how to use each of these APIs.

The Draw Sprites Demo shows off a turtle shell scrolling vertically and horizontally on the screen. DrawSprites() can automatically handle showing/hiding sprites at the edge of the screen.

The Draw Sprite Block Demo shows off how to draw a grid of sprites from memory, directly onto the display. This works best when you don't have Pixel Vision 8 automatically optimize sprites in memory and you know they will always their upper left-hand corner ID. DrawSpriteBlock() also leverages DrawSprites() so you get the same ability to automatically show/hide sprites at the edges of the screen.

With a little bit of planning, it shouldn't be hard to recreate some of the same techniques used on the Nintendo to get the most out of Pixel Vision 8's sprite renderer.
No comments yet
Write a comment...


Includes access to 4 products:
Get access