Nilorea Library

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
Functions
n_anim.c File Reference
`#include "n_common.h"`
`#include "n_str.h"`
`#include "n_gfx.h"`
`#include "n_anim.h"`
Include dependency graph for n_anim.c:

Go to the source code of this file.

## Functions

int | init_sprite (SPRITE **spr, char *name, int w, int h, int x, int y, int type, int delay, int max)
| init a SPRITE object with given parameters (pass -1 for id and delay if unavailable) More...
int | add_bmp_to_spr (BITMAP *bmp, SPRITE *spr)
| Add if possible a bimtap to a sprite. More...
int | read_sprite_in_file (PACKFILE *file, SPRITE **spr)
| read a sprite in an opened file More...
int | write_sprite_in_file (PACKFILE *file, SPRITE *spr)
| write a sprite in an opened file More...
SPRITE * | GetOldSprite (char *bmpfilename, char *txtfilename, char *name)
| load an old sprite file to a new sprite pointer More...
int | blit_sprite (SPRITE *sprite, int x, int y, int frame, BITMAP *bmp)
| draw a sprite at the right position More...
int | free_sprite (SPRITE **spr)
| Free a sprite from memory. More...
int | create_animlib (ANIM **lib, char *name, int nbspr)
| create a big library of animations More...
int | create_iso_animlib (ISO_ANIM **lib, char *name, int nbspr)
| create a big iso library of animations More...
int | load_animlib (PACKFILE *file, ANIM **lib)
| load an anim file from disk , return FALSE if : not existing and error creating : existing and error reallocating if not enought big) More...
int | save_animlib (PACKFILE *file, ANIM *lib)
| save an anim library to disk ( cropping the various arrays ) More...
int | add_sprite_to_lib (SPRITE *spr, ANIM *lib)
| add sprite to lib More...
int | remove_sprite_from_lib (ANIM *lib, int id)
| remove sprite from library More...
int | free_anim (ANIM *lib)
| free an anim library More...
int | resize_anim_lib (ANIM **lib, int nb)
| Resize your lib for reach (if possible) nb elements. It will reduce to a maximum of lib->hightest elements, or grow to memory allowed maximum elements. If an error occur, a roll back will be performed. More...
int | blit_anim (ANIM *lib, int id, int x, int y, int frame, BITMAP *bmp)
| draw a sprite at the right position More...
int | exist_sprite (ANIM *lib, char *name)
| check if a sprite already exist in a lib More...

## Detailed Description

2D animations functions and library for IsoEngine

Author
  Castagnier Mickael

Version
  1.0

Date
  19/07/05

Definition in file n_anim.c.

## Function Documentation

int add_bmp_to_spr | ( | BITMAP * | bmp,
|  | SPRITE * | spr
| ) |  |

Add if possible a bimtap to a sprite.

Parameters

  bmp | a bitmap to add to the sprite
  spr | a SPRITE where to add the bmp

Returns
  FALSE if spr is full or if error, TRUE else

Definition at line 116 of file n_anim.c.

Here is the call graph for this function:

int add_sprite_to_lib | ( | SPRITE * | spr,
|  | ANIM * | lib
| ) |  |

add sprite to lib

Parameters

  spr | SPRITE to add
  lib | ANIM lib where add the sprite

Returns
  TRUE on success, FALSE on error

Definition at line 763 of file n_anim.c.

int blit_anim | ( | ANIM * | lib,
|  | int | id,
|  | int | x,
|  | int | y,
|  | int | frame,
|  | BITMAP * | bmp
| ) |  |

draw a sprite at the right position

Parameters

  lib | an ANIM library where found the sprite
  id | ident of the sprite to blit
  x | where to put sprite on BITMAP , X
  y | where to put sprite on BITMAP , Y
  frame | frame of sprite to blit
  bmp | BITMAP object where blit sprite

Returns
  TRUE or FALSE (if not valid frame ie)

Definition at line 946 of file n_anim.c.

Here is the call graph for this function:

int blit_sprite | ( | SPRITE * | sprite,
|  | int | x,
|  | int | y,
|  | int | frame,
|  | BITMAP * | bmp
| ) |  |

draw a sprite at the right position

Parameters

  sprite | a pointer where the data are
  x | where to put sprite on BITMAP , X
  y | where to put sprite on BITMAP , Y
  frame | frame of sprite to blit
  bmp | BITMAP object where blit sprite

Returns
  TRUE or FALSE (if not valid frame ie)

Definition at line 412 of file n_anim.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int create_animlib | ( | ANIM ** | lib,
|  | char * | name,
|  | int | nbspr
| ) |  |

create a big library of animations

fn create_animlib( ANIM **lib , char *name , int nbspr )

Parameters

  lib | an animations library
  name | name of library
  nbspr | number of animations in library

Returns
  TRUE or FALSE

Definition at line 543 of file n_anim.c.

Here is the caller graph for this function:

int create_iso_animlib | ( | ISO_ANIM ** | lib,
|  | char * | name,
|  | int | nbspr
| ) |  |

create a big iso library of animations

fn create_iso_animlib( ANIM **lib , char *name , int nbspr )

Parameters

  lib | an animations library
  name | name of library
  nbspr | number of animations in library

Returns
  TRUE or FALSE

Definition at line 596 of file n_anim.c.

int exist_sprite | ( | ANIM * | lib,
|  | char * | name
| ) |  |

check if a sprite already exist in a lib

Returns
  If exist, it return the aimed sprite index, it return -2

Definition at line 965 of file n_anim.c.

int free_anim | ( | ANIM * | lib | ) |

free an anim library

Parameters

  lib | a lib to free

Returns
  TRUE or FALSE

Definition at line 829 of file n_anim.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int free_sprite | ( | SPRITE ** | spr | ) |

Free a sprite from memory.

Parameters

  spr | A SPRITE *spr to kill

Returns
  TRUE

Definition at line 506 of file n_anim.c.

Here is the caller graph for this function:

SPRITE* GetOldSprite | ( | char * | bmpfilename,
|  | char * | txtfilename,
|  | char * | name
| ) |  |

load an old sprite file to a new sprite pointer

Parameters

  bmpfilename | location of the bitmap part of old sprite format
  txtfilename | location of the text part of old sprite format
  name | name of the new sprite

Returns
  a pointer to the loaded new SPRITE or NULL

Definition at line 296 of file n_anim.c.

Here is the call graph for this function:

int init_sprite | ( | SPRITE ** | spr,
|  | char * | name,
|  | int | w,
|  | int | h,
|  | int | x,
|  | int | y,
|  | int | type,
|  | int | delay,
|  | int | max
| ) |  |

init a SPRITE object with given parameters (pass -1 for id and delay if unavailable)

Parameters

  spr | SPRITE object to init
  name | the name of the sprite
  w | width of the sprite(s) in the SPRITE object
  h | height of the sprite(s) in the SPRITE object
  x | X position of the center of the sprite
  y | Y position of the center of the sprite
  type | 0 -> normal ; blit 1 -> MASKED ; 2 -> translucent
  delay | -1 or number of milisec between frames
  max | number of maximum images in SPRITE object

Returns
  TRUE or FALSE

Definition at line 46 of file n_anim.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int load_animlib | ( | PACKFILE * | file,
|  | ANIM ** | lib
| ) |  |

load an anim file from disk , return FALSE if : not existing and error creating : existing and error reallocating if not enought big)

Parameters

  file | an opened PACKFILE *file where read an anim lib
  lib | a pointer to the futur library

Returns
  TRUE on success FALSE on failure

Definition at line 670 of file n_anim.c.

Here is the call graph for this function:

int read_sprite_in_file | ( | PACKFILE * | file,
|  | SPRITE ** | spr
| ) |  |

read a sprite in an opened file

Parameters

  file | an opened PACKFILE *file to read in
  spr | a SPRITE pointer to point the sprite in memory

Returns
  FALSE if not valid file or writing error or memory error TRUE else

Definition at line 149 of file n_anim.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int remove_sprite_from_lib | ( | ANIM * | lib,
|  | int | id
| ) |  |

remove sprite from library

Parameters

  lib | the lib where remove sprite
  id | the id of the sprite to remove

Returns
  TRUE on success, FALSE on error

Definition at line 799 of file n_anim.c.

Here is the call graph for this function:

resize_anim_lib | ( | ANIM ** | lib,
|  | int | nb
| ) |  |

Resize your lib for reach (if possible) nb elements. It will reduce to a maximum of lib->hightest elements, or grow to memory allowed maximum elements. If an error occur, a roll back will be performed.

Parameters

  lib | A pointer to a ANIM *library
  nb | An int value to reach

Returns
  1 if not possible but not error , 2 if not possible but roll back is successfull , 3 if success

Definition at line 863 of file n_anim.c.

Here is the call graph for this function:

int save_animlib | ( | PACKFILE * | file,
|  | ANIM * | lib
| ) |  |

save an anim library to disk ( cropping the various arrays )

Parameters

  file | an opened PACKFILE *file where save an anim lib
  lib | the library to save

Returns
  FALSE if error TRUE else

Definition at line 720 of file n_anim.c.

Here is the call graph for this function:

int write_sprite_in_file | ( | PACKFILE * | file,
|  | SPRITE * | spr
| ) |  |

write a sprite in an opened file

Parameters

  file | an opened PACKFILE *file to write in
  spr | a SPRITE pointer to know the data

Returns
  FALSE if not valid file or writing error or memory error TRUE else

Definition at line 225 of file n_anim.c.

Here is the caller graph for this function: