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.0
-
- Copyright (C) Jari Karjala 1990
-
- 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"
-
-
- #ifndef __ANIM_SPRITE_
- typedef void *ANIM_SPRITE;
- #endif
-
- /**********************************************************************
- * 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;
-
-
- /**********************************************************************
- * The values for fx_mode and fx_type. (See spr_anim_set_fx_handler)
- **********************************************************************/
- #define SPR_ANIM_FX_ALL (0xFFFF) /** 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
- **********************************************************************/
- #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 **/
-
-
-
- /**********************************************************************
- * Create an animated sprite from the given simple sprites.
- * The sprites must have the same width and height attributes.
- * 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
- * ... The simple sprites
- *
- * Return: ANIM_SPRITE if no errors or
- * NULL if memory allocation error, count>ANIM_SPRITE_MAX
- * or ... contains a NULL sprite.
- **********************************************************************/
- ANIM_SPRITE spr_anim_create(WORD count, ...);
-
- /**********************************************************************
- * Start the sprite animation.
- *
- * aspr The animated sprite to use
- **********************************************************************/
- void spr_anim_start(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.
- *
- * aspr The animated sprite to stop
- **********************************************************************/
- void spr_anim_stop(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_delete(ANIM_SPRITE aspr);
-
- /**********************************************************************
- * Delete the given animated sprite. The simple sprites it contains are
- * ALSO deleted.
- *
- * aspr The animated sprite to destroy
- **********************************************************************/
- void spr_anim_destroy(ANIM_SPRITE aspr);
-
- /**********************************************************************
- * spr_put all animated sprites then check for special effects (call
- * fx_handler(s) if necessary, and act according to the return values).
- * Call spr_next_pass and after that update frame indices and locations
- * of all animated sprites.
- *
- * Return: The current visual page
- **********************************************************************/
- WORD spr_anim_next_pass(void);
-
-
-
- /**********************************************************************
- * 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.
- **********************************************************************/
- ANIM_SPR_INFO *spr_anim_get_info(ANIM_SPRITE aspr);
-
- /**********************************************************************
- * Set the location of the animated sprite.
- **********************************************************************/
- void spr_anim_set_location(ANIM_SPRITE aspr, WORD x, WORD y);
-
- /**********************************************************************
- * Set the movement vector of the animated sprite.
- **********************************************************************/
- void spr_anim_set_vector(ANIM_SPRITE aspr, int dx, int dy);
-
- /**********************************************************************
- * Set the limits for the animated sprite. The function takes care
- * of the bottom/right adjustments due to the size of the sprite.
- *
- * Note again, that all simple sprites belonging to the animated sprite
- * must have the same width & heigth.
- **********************************************************************/
- void spr_anim_set_limits(ANIM_SPRITE aspr,
- WORD lef, WORD top, WORD rig, WORD bot);
-
-
- /**********************************************************************
- * 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_time(ANIM_SPRITE aspr,
- int frame, int frame_delay, int timeout);
-
- /**********************************************************************
- * Sets the special effects handler function.
- * The function should have the following prototype:
- *
- * WORD func(ANIM_SPRITE aspr, WORD fx_type, SPRITE spr);
- *
- * The aspr is the animated sprite, fx_type is the type of the
- * effect which caused this call and spr is the colliding sprite
- * (if fx_type was HIT_SPRITE).
- *
- * The function should return one of the FX_RET values defined above.
- *
- * A NULL handler means that all special effects cause spr_anim_delete.
- *
- * fx_mask The types of effects relayed to the handler.
- * fx_handler The handler function.
- **********************************************************************/
- void spr_anim_set_fx_handler(ANIM_SPRITE aspr,
- WORD fx_mask,
- WORD (fx_handler)(ANIM_SPRITE,WORD,SPRITE));
-
- #endif
-
-