/*
 * Sprite.h - Sprite Header file
 * By: Odis
 */
#ifndef INC_SPRITE
#define INC_SPRITE
 
typedef struct sprite_data SPRITE;

struct sprite_data
{
  SPRITE *        next;
  SPRITE *        prev;
  BMP    *        bitmap;
  POINT           position;
  POINT           oldpos;
  POINT           velocity;
  RECT            bounds;
  RECT            collision;

  bitmask_t      *bitmask; /* for collisions, no scripts can touch this */
  
  char           *name;
  bool            hidden;  /* sprite hidden? */
  bool            drag;    /* can you drag this sprite? */
  bool            gravity; /* does gravity affect this sprite? */
  bool            proto;   /* can this sprite be modified? dont think so! MWAHAHAHAHAHA! err, use this sprite for copying if true */
  int             z;
  int             action; /* action taken if sprite hits border */
  int             direction;  /* LEFT or RIGHT? */
  int             type; /* see list */

  int             width;
  int             height;
  
  /* for animation */
  int             frames;
  int             current_frame;
  int             delay;
  int             trigger;
};

/* sprite types */
typedef enum
{
  S_NONE, PLAYER, ENEMY, BOSS, PROJECTILE, P_PROJECTILE
} sprite_types;

/* actions taken if sprite hits border */
typedef enum
{
  STOP, WRAP, BOUNCE, DIE
} action;

/* resulting actions */
typedef enum
{
  rKILL, rNONE
} resulting_actions;

/* functions */
SPRITE *sprite_from_bitmap( BMP *bitmap, int frames, int delay, char *name );
SPRITE *sprite_from_initial( BMP *bitmap, POINT position, POINT velocity,
                            int z, RECT bounds, int action, int width, int height, char *name, int type );
SPRITE *is_point_in_sprite( int x, int y );

bool SpriteCollision(SPRITE *hitter, SPRITE *hittee);
bool CheckSpriteCollision(SPRITE *sprite);
bool TestCollision( SPRITE *sprite1, SPRITE *sprite2 );

int update_sprite( SPRITE *sprite );

void CalcCollisionRect( SPRITE *sprite );
void draw_sprite(SPRITE *sprite, HDC hDC);
void DrawSprites( SPRITE *sprite, HDC hDC );
void DrawFrame( SPRITE *sprite, HDC hDC );
void update_frame( SPRITE *sprite );
void link_by_zorder( SPRITE *sprite );
void CleanSprites( void );
void UpdateSprites( void );

void SetVelocity( SPRITE *sprite, int x, int y );
void SetPosition( SPRITE *sprite, POINT position );

#endif