class is the core behind all sprite-types introduced in GALVADERS.
Once you grasp how to work with this class, you know the concept of how GALVADERS is built.
How to work with this class:
RLE_SPRITE **dt This is RLE_SPRITE * vector (see create_game_params()
about how create this vector from Allegro DATAFILE).
This pointer should be valid at all time.
BITMAP *dst This is the dest-BITMAP where you want to write sprite-output.
This should be your back-ground buffer.
pos_x,pos_y The sprite location on dest-BITMAP.
z_order This is the Z-Order value for the sprite. Some games don't use this.
sprite_index This is the index of the sprite-image. Thus, dt[sprite_index] gives the sprite address.
bg_flag When this flag is set, the base_image
object retains sprite's background when removing it from dest-BITMAP. When clear, a black rectangle is drawn.
Once constructed a base_image
object the way of work is simple,
just issue a remove()
for each and every frame.
removes RLE_SPRITE from dest-BITMAP.
write RLE_SPRITE to dest-BITMAP.
The virtual method action()
, once you derive your own sprite-class from base_image
add all the game-logic code for your object in the action()
Thus, having all kinds of objects derived from base_image
construct an STL-list or vector of base_image *
, and for each an every frame the remove()
is virtual, the right action-method would be called for each object type.
Do a reverse-scan of the list when doing the remove()
section, and forward-scan for
This keep your dest-BITMAP clean from trails of moving objects.
Take a look at base_image.h
for available base_Image methods. I think all of them are straight forward.
Read the code in base_image.cpp
for better understanding, it's simple.
To make things easy, this page will be updated later.
There is another base_image class, not used in GALVADERS, that works directly with Allegro DATAFILE array. This one does not require RLE_SPRITE vector-pointer, but a DATAFILE pointer instead. The DATAFILE pointer should be valid all time.