 |

 HUD painting

The top area of the game screen, presenting the room's name, the life bar, the credits and the found coins is called the HUD.
The HUD is responsable for painting all these, including the screen borders, cover, and even the dialog messages, or other menus.
In fact, it paints everything, except the game room's view and it's content.
It does all that, through a draw handler, HandlerDrawHud, that is called by the
engine after the room's content was painted. In this handler the user can place code to paint the HUD and customize it as needed.
For simple games, the beginners can just change the menu tile used for the HUD, data/tiles/menu/1 menu.tga,
providing a different look, but keeping the position for the text areas. If these have to be rearranged, a few adjustments of the
coordinates in the draw handler, are needed. For more complex HUDs, more of the hud handler can be changed.
|
|
HudDrawTile( tileid, x, y, w, h, mapx, mapy, mapw, maph, flip, frame )
This function, exported by the engine, is used to draw a tile or a part of it on the screen.
It uses the tile's id and a destination rectangle given by position (x,y) and it's width and height (w x h).
It has mapping coordinates in the tile's image, and flip and frame options, similar to brushes.
The mapped area of the tile is repeated inside the destination rectangle.
See the reference.
HudDrawText( tileid, x, y, w, h, text, align )
This function, exported by the engine, is used to draw a text on the screen.
It uses the font tile's id and a destination rectangle given by position (x,y) and it's width and height (w x h).
The defaut font tile contains characters of 8x8 pixels, in a specific order
(data/tiles/menu/4 font.tga).
The text is displayed using the current font format, specified through the
HudFont function.
More about fonts and their format in a moment.
The text is aligned inside the destination rectangle, as the align option requests (-1=left, 0=center, 1=right).
See the reference.
The above draw functions use current values for color and shader,
set though the HudColor and HudShader exported functions.
|
The HandlerDrawHud function is called very often by the engine, so extensive scripting inside it may influence the game's speed on slower computers.
It is recommended to optimize your code you write inside this handler. Don't use too many string operations and keep it as simple as possible.
If needed, do constant calculus outside, or provide defines, or exact values for parameters. Don't request latent functions from it.
The game screen is 256x192 pixels, as Z80 computers displays.
This area is centered by the engine in the application window, leaving smaller or bigger borders, depending on the rezolution
selected for the game, by the player. You can paint on these borders too, by specifying negative coordinates to the draw functions, but
you must take in consideration that the game rezolution is variable and only the 256x192 area is guaranteed to be fully visible.
A resolution of 640x480 with scale 2x, or 320x240 with scale 1x, is considered to be standard for most computers, when running DizzyAGE games.
So, this leaves two side borders of (320-256)/2 = 32 pixels each, that can contain additional border graphics.
|
|
The so called cover image, is by default part of the menu tile and the hud handler paints it, if the user requests by setting the
global game property G_COVER to 1. It is displayed over the room's content, hiding it,
for main menu purposes. It usually represents a nice painted screen, specific to the game. Like a book cover.
|
|
|
The loading screen is also painted by the hud handler, while the rest of the game's data is loaded.
It's tile is data/tiles/loading/6 loading.tga and it's loaded prior to any other game's data.
Then, the GameStartLoad function does a latent stop, allowing the hud handler to be called
once to paint this tile on the whole game's screen. If the game loads a lot of graphic tiles, this may take a few seconds and a loading
screen is a nice way to hide it. It can also prezent the legal licence text, required by all Dizzy games.
The game remembers if it's started for the first time, or if it's restarted after some playing, by storing this info in the
global game property G_RESTART and this is also used by the hud handler to know if it should
paint the loading screen or the normal hud look.
|
|
|
The hud handler is also responsable for painting the current opened dialogs.
It does that by calling the DialogDraw function, for each of them.
It uses dialog proeprties, like position, size, text, color, etc, to paint it, using the same draw functions presented above.
Advanced users can customize dialogs painting, considering their additional user properties.
See the reference.
|
 Fonts format

DizzyAGE fonts can be created using the FontWorks tool and they consist of two components.
One is the font tile, a TGA file with all the supported characters, usually aligned in a table.
The other one is a font format, a FNT file with information about the positions and sizes of
the characters in the font tile.
The font format files have the same naming convention, as other resources.
Their file names start with an id, that usually is the same one to the coresponding tile,
followed by a space character and a small representative name.
ID fontname.fnt
The default Dizzy font has charcaters of 8x8 pixels, but DizzyAGE supports different font formats too.
Even formats with characters that have different widths.
 Homework
Try to play with the hud handler a little, paint another menu tile in your graphic editor and rearrange the displayed texts.
For more detalis see the hud reference chapters.
Engine exported hud functions
|
 |