What is a Sprite: Are Sprites:

Wikipedia suggests that a Sprite is a class of preternatural legendary creatures commonly associated with elves, fairies, pixies, and spirits. Of course this is not what is meant when Programmers are discussing them in most cases.
fairy.jpg

Within the realm of Liberty Basic programming we are referring to a two-dimensional pre-rendered graphics figure, usually containing some transparency. Liberty Basic implements sprites using Windows GDI function calls that allow manipulation of graphics with masked areas using an XOR bit copy. This is not critical to understand in order to use Sprites, but may help explain their operation if you wish to dig deeper into this area.

Create a Sprite:

Sprites are created by selecting a suitable graphic (in bitmap form) and applying a mask. Masks are black (RGB = 0). A suitable graphic should not have any black in it unless you want that area to be transparent. If the graphic you choose has black use a graphic editing program and replace the black with a very very dark gray.

Using the image of the sprite (or pixy as we will call her from now on to avoid confusion) we must do the following to create a sprite that LB can use.
1) Change any black in the image to a just off black. There was none in this case.
2) Flood fill any background area we want to be transparent with black:

fairy2.jpg
3) Last create a mirror image of the graphic (the pixy in this case) of equal size and dimension above the image. ( This can be done with this Liberty Basic program found in the helpfile. )


Want to know more?

Read the entire Liberty BASIC Helpfile section on Sprites. It explains what sprites are, how they work, and how to use them. There are plenty of pictures.

Next, check out the articles in the Liberty BASIC Newsletter that pertain to sprites. Download the archives to get all of the images needed to run the demonstration programs.

http://groups.yahoo.com/group/lbnews/
http://babek.info/libertybasicfiles/lbnews/

Beginning Game Programming by Richard Ryles
This series can be found in the following issues:
  • 109
  • 110
  • 111
  • 118

Sprite Bytes by Alyce Watson
This series can be found in the following issues:
  • 119
  • 120
  • 121
  • 122
  • 124
  • 125
  • 126
  • 128
  • 129
  • 132
  • 133
  • 134
  • 137

You can use Game Workshop to create a skeleton for your game. The standalone version is available here:
It is also part of Liberty BASIC Workshop, available here:


Add your favorite sprite resources!