MONOCHROME SPRITES FUNCTIONS (part of games.h)

Header {z88dk}/include/games.h
Source {z88dk}/libsrc/graphics
Include #include <games.h>
Linking n/a
Compile n/a
Comments

These library functions are part of the monochrome graphics functions, thought to be easily portable.

Sprite functions

The sprite functions are based on a special data structure permitting dynamic sprite sizes: the first two bytes define the sprite size, while the next ones describe the picture.

The bits are right-padded to fill the last byte in a row.

getsprite(int x, int y, void *sprite)

Pick up a sprite directly from the screen.

This functions isn’t still working.

putsprite(int ortype, int x, int y, void *sprite)

Draw a sprite of variable size it can behave in three different ways, to be specified in the “ortype” parameter:

SPR_OR

the sprite will just be printed on the screen without deleting what’s already there

SPR_XOR

the sprite will be XORed with the pictures already present on the screen

SPR_AND

the sprite will be “printed in white”, eventually leaving a shape. This feature permits the use of “sprite masks”.

Screen areas save and restore

void bksave(int x, int y, void *sprite)

Saves the screen area in a sprite-like structure. Position and size are saved in it (taking 4 bytes), but the area granularity works at byte-level, to run faster.

Example:


char  *background;

background=malloc( 4 + (width/8+1) * (height) );
sprintf(background, "%c%c",width,height);
bksave(x,y,back);

void bkrestore(void *sprite)

Restores the background area.

Example:


bkrestore(background);

The Sprite editor tool by Daniel McKinnon

This is a simple sprite editor for z88dk with it’s main feature being that it automatically will generate code for you.

Its features make it very useful to create animated sprite arrays and to import external pictures into sprite structures.

How to use

Image Editing

Up / Down......................Zoom In / Out
SHIFT + arrow keys.............Scroll Sprite
H..............................Flip sprite horizontally
V..............................Flip sprite vertically
D..............................Flip sprite diagonally
I..............................Invert Sprite
L..............................Import From BMP or PCX
C..............................Choose Source Sprite for Copying (copy)
P..............................Copy Source sprite to current sprite (paste)
SHIFP + P......................Divide the source sprite into pieces and paste them to the 
                               destination and its following ones.
M..............................Compute mask for copied sprite and paste to current sprite

Saving / Loading

F2.............................Saves all sprites into a sprite file (not code)
F3.............................Load sprites from sprite file (not code)
F5.............................Save code file generating code from sprite 0 - selected
 
library/sprites/monosprites.txt · Last modified: 2007/03/26 09:30 by stefano
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki