home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * spr_anim.h
- *
- * Routines for automatic sprite animation and movement.
- **********************************************************************
- This file is part of
-
- STK -- The sprite toolkit -- version 1.1
-
- Copyright (C) Jari Karjala 1991
-
- The sprite toolkit (STK) is a FreeWare toolkit for creating high
- resolution sprite graphics with PCompatible hardware. This toolkit
- is provided as is without any warranty or such thing. See the file
- COPYING for further information.
-
- **********************************************************************
- **********************************************************************/
-
- #ifndef __SPR_ANIM_H_
- #define __SPR_ANIM_H_
-
- #include "grtypes.h"
-
- /***** Datatypes *****/
-
- #ifndef __ANIM_SPRITE_
- typedef void *ANIM_SPRITE;
- #endif
- /**********************************************************************
- * The animated sprite type is private. The handle must be void pointer
- * due to the TC which does not allow "struct _anim_sprite *ANIM_SPRITE"
- * without a "struct _anim_sprite" defined in the same file.
- **********************************************************************/
-
- /**********************************************************************
- * The information structure returned by the spr_anim_get_info():
- **********************************************************************/
- typedef struct _anim_spr_info {
- int x,y; /** location **/
- int dx,dy; /** movement vector **/
- int lef, top, rig, bot; /** limits **/
- WORD frame, frame_delay, timeout; /** time info **/
- WORD id; /** the user spesified id of current sprite **/
- int w,h; /** width&height **/
- } ANIM_SPR_INFO;
-
- /***** Literal defines *****/
-
- /**********************************************************************
- * The values for fx_mode and fx_type: (See spr_anim_set_fx_handler)
- **********************************************************************/
- #define SPR_ANIM_FX_ALL (0x0F) /** all fx **/
- #define SPR_ANIM_FX_TIMEOUT (1<<0) /** timeout **/
- #define SPR_ANIM_FX_HIT_X_LIMIT (1<<1) /** hit x limit **/
- #define SPR_ANIM_FX_HIT_Y_LIMIT (1<<2) /** hit y limit **/
- #define SPR_ANIM_FX_HIT_SPRITE (1<<3) /** hit other spr**/
-
- /**********************************************************************
- *
- * The FX_RET values for the fx_handler return codes:
- **********************************************************************/
- #define SPR_ANIM_FX_RET_NOTHING (0) /** continue normally **/
- #define SPR_ANIM_FX_RET_RE_PUT (1) /** put the sprite again **/
- #define SPR_ANIM_FX_RET_STOP (2) /** stop the animation **/
- #define SPR_ANIM_FX_RET_DELETE (3) /** delete the anim.sprite **/
- #define SPR_ANIM_FX_RET_DESTROY (4) /** destroy the anim.sprite **/
-
- /***** Function prototypes *****/
-
- ANIM_SPRITE spr_anim_create(WORD count, ...);
- /**********************************************************************
- * Create an animated sprite from the given simple sprites.
- * The sprites must have the same width and height.
- * Set the following defaults:
- * x,y = 0,0
- * dx,dy = 0,0
- * lef,top,rig,bot = 0,0,spr_max_x,spr_max_y
- * frame_delay, timeout = 0,0
- * fx_mode = FX_ALL
- * fx_handler = default_fx (TIMEOUT & HIT_SPRITE delete, LIMITs bounce.)
- *
- * count The number of simple sprites, at most 20.
- * ... The simple sprites
- *
- * Return: ANIM_SPRITE if no errors or
- * NULL if memory allocation error, count>20
- * or ... contains a NULL sprite.
- **********************************************************************/
-
- void spr_anim_start(ANIM_SPRITE aspr);
- /**********************************************************************
- * Start the sprite animation.
- *
- * aspr The animated sprite to use
- **********************************************************************/
-
- void spr_anim_stop(ANIM_SPRITE aspr);
- /**********************************************************************
- * Stop the animation of the given sprite. This means that after the
- * next pass this sprite will not be shown nor updated. Sprite can
- * be restarted with the function spr_anim_start.
- *
- * aspr The animated sprite to stop
- **********************************************************************/
-
- void spr_anim_delete(ANIM_SPRITE aspr);
- /**********************************************************************
- * Delete the given animated sprite. The simple sprites it contains are
- * NOT deleted.
- *
- * aspr The animated sprite to use
- **********************************************************************/
-
- void spr_anim_destroy(ANIM_SPRITE aspr);
- /**********************************************************************
- * Delete the given animated sprite. The simple sprites it contains are
- * ALSO deleted.
- *
- * aspr The animated sprite to destroy
- **********************************************************************/
-
- WORD spr_anim_next_pass(void);
- /**********************************************************************
- * This function handles the sprite animation and display.
- * 1. Spr_put all animated sprites.
- * 2. Check for special effects.
- * a. Call fx_handlers if necessary.
- * b. Act according to the fx_handler return values.
- * 3. Call spr_next_pass.
- * 4. Update frame indices and locations of all animated sprites.
- *
- * Return: The current visual page number
- **********************************************************************/
-
-
-
- ANIM_SPR_INFO *spr_anim_get_info(ANIM_SPRITE aspr);
- /**********************************************************************
- * Return a pointer into a static info structure of the sprite.
- *
- * NOTE: the structure is only a copy which is overwritten by the
- * next call to this function.
- **********************************************************************/
-
- void spr_anim_set_location(ANIM_SPRITE aspr, WORD x, WORD y);
- /**********************************************************************
- * Set the location of the animated sprite.
- **********************************************************************/
-
- void spr_anim_set_vector(ANIM_SPRITE aspr, int dx, int dy);
- /**********************************************************************
- * Set the movement vector of the animated sprite. The (dx,dy) are added
- * to the (x,y) attributes of the sprite during every pass. Negative
- * values mean left and up directions in screen.
- **********************************************************************/
-
- void spr_anim_set_limits(ANIM_SPRITE aspr,
- WORD lef, WORD top, WORD rig, WORD bot);
- /**********************************************************************
- * Set the limits for the animated sprite. The function takes care
- * of the bottom/right adjustments due to the size of the sprite.
- * The fx_handler will be triggered by these limits, if allowed.
- *
- * Note again, that all simple sprites belonging to the animated sprite
- * must have the same width & heigth or the limit checking will not work.
- **********************************************************************/
-
- void spr_anim_set_time(ANIM_SPRITE aspr,
- int frame, int frame_delay, int timeout);
- /**********************************************************************
- * Set the frame delay and timeout values. (-1 means no change for
- * that value).
- *
- * NOTE: The 'frame' MUST NOT be changed from an fx_handler!!
- *
- * frame The current animation frame number (0..nr of frames-1)
- * frame_delay The number of passes for each frame change (0=no change)
- * timeout The number of passes before timeout action (0=infinite)
- **********************************************************************/
-
- void spr_anim_set_fx_handler(ANIM_SPRITE aspr,
- WORD fx_mask,
- WORD (fx_handler)(ANIM_SPRITE,WORD,SPRITE));
- /**********************************************************************
- * Sets the special effects handler function for the given ANIM_SPRITE.
- *
- * The function should have the following prototype:
- *
- * WORD handler_name(ANIM_SPRITE aspr, WORD fx_type, SPRITE spr);
- *
- * The function will be called with the following parameters:
- * aspr the animated sprite whose handler this is,
- * fx_type the type of the effect which caused this call,
- * spr the colliding sprite (if fx_type was HIT_SPRITE).
- *
- * The function must return one of the SPR_ANIM_FX_RET values defined above.
- *
- * A NULL handler means that all special effects cause spr_anim_delete.
- *
- * fx_mask The types of effects which cause a call to the handler,
- * for example: SPR_ANIM_FX_HIT_Y_LIMIT|SPR_ANIM_FX_HIT_X_LIMIT
- * fx_handler The handler function.
- **********************************************************************/
- #endif
-
-