|
SDLGameEngine
|
00001 #ifndef _SGESPRITE_H 00002 #define _SGESPRITE_H 00003 00004 #ifdef __cplusplus 00005 extern "C" { 00006 #endif 00007 00012 /* 00013 * Copyright (c) 2007 Heiko Irrgang 00014 * 00015 * The license and distribution terms for this file may be 00016 * found in the file COPYING in this distribution or at 00017 * http://93-interactive.com/cms/products/software/sdl-game-engine/license/ 00018 */ 00019 00033 typedef struct { 00035 int x; 00037 int y; 00038 } SGESPRITEWAYPOINT; 00039 00042 typedef struct { 00044 int x; 00046 int y; 00048 Uint32 currentFrame; 00050 SGEARRAY *sprite; 00052 SGEARRAY *wayPoints; 00054 void *userData; 00056 int numberOfBanks; 00058 int currentBank; 00060 int animate; 00062 Uint8 alpha; 00064 float moveSpeed; 00066 Uint32 framesPerSecond; 00067 Uint32 lastFrame; 00068 SGEARRAY *bankSize; 00069 Uint32 isMoving; 00070 float fX, fY; 00071 float dirX, dirY; 00072 int initialized; 00073 int initMove; 00074 } SGESPRITE; 00075 00080 SGESPRITE *sgeSpriteNew(void); 00081 00092 SGESPRITE *sgeSpriteNewFile(SGEFILE *f, const char *filename); 00093 00106 SGESPRITE *sgeSpriteNewFileRange(SGEFILE *f, const char *templ, Uint32 start, Uint32 end); 00107 00113 SGESPRITE *sgeSpriteNewSDLSurface(SDL_Surface *surface); 00114 00119 void sgeSpriteDestroy(SGESPRITE *s); 00120 00126 SGESPRITEIMAGE *sgeSpriteGetCurrentFrame(SGESPRITE *s); 00127 00133 void sgeSpriteSetFPS(SGESPRITE *s, Uint32 fps); 00134 00140 void sgeSpriteAddSDLSurface(SGESPRITE *s, SDL_Surface *surface); 00141 00147 void sgeSpriteAddSpriteImage(SGESPRITE *s, SGESPRITEIMAGE *i); 00148 00155 void sgeSpriteAddFile(SGESPRITE *s, SGEFILE *f, const char *name); 00156 00169 void sgeSpriteAddFileRange(SGESPRITE *s, SGEFILE *f, const char *templ, Uint32 start, Uint32 end); 00170 00176 SDL_Surface *sgeSpriteGetSDLSurface(SGESPRITE *s); 00177 00191 void sgeSpriteDraw(SGESPRITE *s, SDL_Surface *dest); 00192 00200 void sgeSpriteDrawXY(SGESPRITE *s, int x, int y, SDL_Surface *dest); 00201 00213 void sgeSpriteDrawRotoZoomed(SGESPRITE *s, float rotation, float zoom, SDL_Surface *dest); 00214 00232 void sgeSpriteDrawXYRotoZoomed(SGESPRITE *s, int x, int y, float rotation, float zoom, SDL_Surface *dest); 00233 00240 void sgeAnimatedSpriteUseAlpha(SGESPRITE *s); 00241 00249 void sgeAnimatedSpriteIgnoreAlpha(SGESPRITE *s); 00250 00260 int sgeSpriteBoxCollide(SGESPRITE *a, SGESPRITE *b); 00261 00274 int sgeSpriteCollide(SGESPRITE *a, SGESPRITE *b); 00275 00285 int sgeSpriteBoxCollideSpriteImage(SGESPRITE *a, SGESPRITEIMAGE *b); 00286 00293 int sgeSpriteCollideSpriteImage(SGESPRITE *a, SGESPRITEIMAGE *b); 00294 00300 int sgeSpriteWidth(SGESPRITE *s); 00301 00307 int sgeSpriteHeight(SGESPRITE *s); 00308 00318 void sgeSpriteAddWayPoint(SGESPRITE *s, int x, int y); 00319 00324 void sgeSpriteRemoveNextWayPoint(SGESPRITE *s); 00325 00330 void sgeSpriteClearWayPoints(SGESPRITE *s); 00331 00340 void sgeSpriteStartMovement(SGESPRITE *s, float speed); 00341 00346 void sgeSpriteAbortMovement(SGESPRITE *s); 00347 00356 void sgeSpriteMoveTowards(SGESPRITE *s, int x, int y); 00357 00363 void sgeSpriteSetUserData(SGESPRITE *s, void *data); 00364 00370 void *sgeSpriteGetUserData(SGESPRITE *s); 00371 00385 void sgeSpriteUpdatePosition(SGESPRITE *s); 00386 00398 void sgeSpriteUpdate(SGESPRITE *s); 00399 00405 Uint32 sgeSpriteGetNumberOfFrames(SGESPRITE *s); 00406 00412 void sgeSpriteSetNumberOfFrames(SGESPRITE *s, Uint32 number); 00413 00419 SGEARRAY *sgeSpriteGetCurrentSpriteArray(SGESPRITE *s); 00420 00426 void sgeSpriteSetAnimBank(SGESPRITE *s, Uint32 bank); 00427 00435 void sgeSpriteAddAnimBank(SGESPRITE *s); 00436 00442 Uint32 sgeSpriteGetAnimBank(SGESPRITE *s); 00443 00449 void sgeSpriteAnimate(SGESPRITE *s, int state); 00450 00455 void sgeSpriteResetAnimation(SGESPRITE *s); 00456 00462 void sgeSpriteForceFrame(SGESPRITE *s, Uint32 frame); 00463 00472 SGESPRITE *sgeSpriteDuplicate(SGESPRITE *s); 00473 00474 // }@ 00475 00476 #ifdef __cplusplus 00477 } 00478 #endif 00479 00480 #endif