create :
it's very easy : struct gfx my_gfx_object
;
load :
load
an bitmap into a gfx object
load
anims into a gfx object
load
many anim who are in the same bitmap in a gfx object
load
an bitmap into a gfx object
sorry, not write set_gfx function to load unique image into
a gfx objet
due to using of real size and pos of frames, not easy to define
object at 'hand' ^^'
but you can use load anim to load one or many image into your
object
load
anims into a gfx object
by default you can load 30 anims max into a gfx object (you
can modifi this value in the file stucture.h)
these anims are make with the gfx object image bank
to load an anim into a gfx object, use load_anim function
void
load_anim(struct gfx * gfx,char id_anim,unsigned char frm_start,unsigned
char frm_number,unsigned char * anim,unsigned short time, char
repeat,char sens, unsigned short sx,unsigned short sy,unsigned
short px,unsigned short py,unsigned short tr_color)
struct gfx *
gfx pointer
to the gfx object
char id_anim
the
animation number of the gfx object where load the anim
char frm_start
the frame number in the gfx object
image bank where start to load the anim frames
char frm_number number
of frames in the anim
unsigned char
* anim pointer to the anim
bitmap
unsigned short
time time
between 2 frames
char repeat type
of anim : 0=123 1=123212.. 2=123123.. 3=123333.. 4=123111..
char sens anim
way : 0=123 1=321
unsigned short
sx y
size in pixel of a frame
unsigned short
sy x
size in pixel of a frame
unsigned short
px pos
x where the gfx object will be init
unsigned short
py pos
y where the gfx object will be init
unsigned short
tr_color gfx object transparent color
exemple, to load these 4 anims of link in the same gfx object

struct gfx link ; //
declare the gfx object
// load anim of link walk left, in anim
0 of the gfx object link, load at frame 0 of the gfx image bank,
7 frames, 75ms between 2 frames, animate in 123123, frame size
is 16*24, gfx object link is init at pos 170*110, transp color
is 0xB3
load_anim(&link,0,0,7,(unsigned char *)walk_left,75,2,0,16,24,170,110,0xB3)
;
load_anim(&link,1,7,7,(unsigned char *)walk_right,75,2,0,16,24,170,110,0xB3)
; // load anim
1 : walk right (start load in frame 7 due to the anim 0 who
are load in part 0-6 of the image bank)
load_anim(&link,2,14,9,(unsigned char
*)walk_down,75,2,0,16,24,170,110,0xB3) ; //
load anim 2 : walk down (start load in frame 7+7=14)
load_anim(&link,3,23,9,(unsigned char
*)walk_up,75,2,0,16,24,170,110,0xB3) ; //
load anim 3 : walk up (start load in frame 7+7+9=23)
all anims load in a same gfx object must have the same frame
size,
the load anim function scan bitmap to search real image position
and size to just draw what is needed,
so, you can use big frame size for easily add and group movements
in the same gfx object :-)
in previous link's anims, we'll can't load the sword anim due
to the size of the gfx object who's 16*24 and sword anim size
is 32*32

the best is to set frame size at frame size of the bigger anim
(in zelda it will be the cyclon attack) and center all anim
on this size
by exemple, zeubdal use frame of 112*128, it's ok for all movements

load
many anim who are in the same bitmap in a gfx object

21 frames of 32*32 pixels for 3 anim in this bitmap
code to load these 3 anim into a gfx object :
struct gfx perso ; // declaration
of the gfx object
// define all the image as only one anim (one anim of
21 frame) with info of the first real anim (with only 2 frames)
load_anim(&perso,0,0,21,(unsigned char
*)perso_img,150,2,0,32,32,135,0,0xB3) ; // load
anim at image 0 of the gfx object img bank, 21 frames, source
bitmap : perso_img, 150ms between frames, anim type 123123,
frame size : 32*32, init gfx object at pos 135,0 transp color
is 0xB3
// modifi anim 0 for stop at frame 2 (frame 2 of image bank
of the gfx object)
perso.animation[0].frame_stop = 2 ;
// now all anims frames are load into the gfx object, time to
define the anim 1 and 2 with these frames
set_anim(&perso,1,2,4,100,1,0)
; // declare the anim 1, start at frame 2 and stop at frame
4, 100ms between every frames, anim type 1232123
set_anim(&perso,2,5,20,55,2,0) ;
// declare the anim 2, start at image 5 and stop at frame 20,
55ms between every frames, anim type 123123
// the 3 anim are load :-)
caution : frame_stop parametter got first frame as 1, set_anim
function first frame is 0
gfx's
draw functions
* draw_gfx
this function draw a specific frame of
the image bank of a gfx object
image will be draw at pos_x pos_y gfx's
object properties
with this function, the pos is define
on the screen
void
draw_gfx(struct
gfx * gfx, char sens, unsigned char img_id)
struct gfx * gfx
pointer
to the gfx object
char sens 0
: normal display 1 : display image inverted
// cut function not
support inverted image, same as colision functions, don't use
this option
unsigned char
img_id the image number in the gfx image bank to draw
* draw_gfx_xy
this function draw a specific frame of
the image bank of a gfx object at the specified position
with this function, the pos is define
on the screen
void
draw_gfx_xy(struct
gfx * gfx, short x, short y, char sens, unsigned char img_id)
struct gfx * gfx
pointer
to the gfx object
short x the
x pos where the image will be draw
short y the
y pos where the image will be draw
char sens 0
: normal display 1 : display image inverted
unsigned char
img_id the image number in the gfx image bank to draw
* play_anim
this function draw and animate the specified
anim of a gfx object
anim will be draw at pos_x pos_y gfx's
object properties
with this function, the pos is define
on the screen
void
play_anim(struct
gfx * gfx, char id_anim, unsigned char sens)
struct gfx * gfx
pointer
to the gfx object
char id_anim the
animation number to draw
char sens 0
: normal display 1 : display image inverted
* play_anim_xy
this function draw and animate the specific
anim of a gfx object at the specified position
with this function, the pos is define
on the screen
void
play_anim_xy(struct
gfx * gfx, char id_anim, short x, short y, unsigned char sens)
struct gfx * gfx
pointer
to the gfx object
char id_anim the
animation number to draw
short x the
x pos where the anim will be draw
short y the
y pos where the anim will be draw
char sens 0
: normal display 1 : display image inverted
draw routine with gfx's coordonates define on a map :
* draw_gfx_on_map
void draw_gfx_on_map(struct gfx * gfx, struct
map * map, char sens, unsigned char img_id)
struct gfx *
gfx pointer
to the gfx object
struct map *
map pointer to the
map object
char sens 0
: normal display 1 : display image inverted
unsigned char
img_id the image number in the gfx image bank to
draw
* play_anim_on_map
void play_anim_on_map(struct gfx * gfx, struct
map * map, char id_anim, unsigned char sens)
struct gfx *
gfx pointer
to the gfx object
struct map *
map pointer to the
map object
char id_anim
the
animation number to draw
char sens 0
: normal display 1 : display image inverted
gfx's
colisions routines
* test_colision_zone
this function
test zone colision between 2 gfx object
short
test_colision_zone(struct gfx * sprite1, struct gfx * sprite2,char
type)
struct gfx *
sprite1 pointer
to the gfx object 1
struct gfx *
sprite2 pointer
to the gfx object 2
char type type
of colision test : if type = 0, test only if the 2 images box
colide, return 0 or 1
if
type = 1, return a number between 1 and 9 who are the zone where
the sprite 2 colide on sprite 1
1
2 3
4
5 6 0
7
8 9
* test_colision_pixel
this function
test pixel colision between 2 animated gfx objects
short
test_colision_pixel(struct gfx * sprite1, struct gfx * sprite2,
char anim_1, char anim_2, char count,unsigned short trace)
struct gfx *
sprite1 pointer
to the gfx object 1
struct gfx *
sprite2 pointer
to the gfx object 2
char anim_1
the
animation number of the sprite 1 to test
char anim_2
the
animation number of the sprite 2 to test
char count define
if function stop at the first detection (0) or count and return
the number of pixel in 'contact' (1)
unsigned short
trace if
trace is != 0 and count is enabled, the function draw in the
color equal at the trace value all pixels who are in colision