domingo, 8 de octubre de 2017

Last Crown Warriors #2: Selection screen

Yesterday Light Games published a new development of Last Crown Warriors, in which the character and scenario selection screen was shown.
In the video we can see how the movement of two backgrounds occurs simultaneously (the selection bar and the map at the top). And we can also see a non-linear movement, with accelerations and decelerations.

At logic level, achieving these features in a program should not be a big challenge. Although in the case of the Game Boy, given the limitations of the system, a little prior planning is necessary. So leaving aside the technicalities and focusing on the logical design I'll explain the key elements of this selection screen.

 

Sinusoidal movement

In order to achieve greater dynamism, it has been decided to apply a sinusoidal movement in the shifts of the bar, the top map, the arrows, and the selectable characters. Calculating the sine of a number would be an overly expensive task for a Game Boy, so a little part of the memory has been sacrificed and these shifts have been stored in data tables.

By going throught the values of a table like this, we can apply to the elements the proper movement in each iteration. This table represents the top map shift when leaving the screen.

 

Scene composition

The logic of this screen uses some of the properties of the Game Boy system, such as hardware scroll or sprites. In this image the components are differentiated by color.


In red: sprites; in blue: the main background; in purple: the secondary background or window.

As you can see, moving the top scenario is as simple as applying the Game Boy hardware scroll on the main background. Of course, you have to keep in mind that this map must be redrawn. In this case there is only one selectable scenario, but in the case of having more than one, it would be necessary to reprint the background with each selection change. In the following image we see the evolution of the main background during that change.


This is the Game Boy main background, the red box being the visible area of the screen during the scenario change. Through one limit of the visible area we first remove the current map and later we print the new one.

The window have a disadvantage. It is not possible to reduce its horizontal coordinate below zero, which would be the natural way to make it enter the left limit of the screen. So as you can see, we use an auxiliary sprite during the movement that joins the bar.

Graphical update

In addition to the shifts there are also times when we have to reload the graphics of the backgrounds. The most obvious (and costly) of these reloads is the update of the window once the selection shift ends and all the icons alter their order.

The solution is to have a strict control of the VBlank interruption, and to optimize the graphic reprint. This routine is the responsible for reloading the window, and already has the list of values to copy ready. The formula in this case is the same as the one used in the Last Crown Warriors scroll, which I explain in this entry.


Now it's time to develop the game system of Last Crown Warriors. Any functionality that deserves to be explained, will be the focus of the next blog entries.

No hay comentarios:

Publicar un comentario