ParticleEngine.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef __CPARTICLEENGINE__
  2. #define __CPARTICLEENGINE__
  3. #include "TileInterfaces.h"
  4. #define MAX_PARTICLES 512
  5. struct SParticleSprayType;
  6. struct SParticle {
  7. int x,y, size, angle;
  8. int dx, dy, sizeinc, angleinc;
  9. int lifeTime;
  10. unsigned int userData;
  11. unsigned int tileIndex;
  12. SParticleSprayType *spray;
  13. };
  14. typedef void (*PARTICLERENDERFUNCTION_TYPE) ( void *data, SParticle *p );
  15. struct SParticleSprayType {
  16. int renderType;
  17. int gravity;
  18. int fraction;
  19. int lifeTime;
  20. int lifeTimeRandom;
  21. int size;
  22. int sizeRandom;
  23. int sizeInc;
  24. int sizeIncRandom;
  25. int angle;
  26. int angleRandom;
  27. int angleInc;
  28. int angleIncRandom;
  29. int firstBlock;
  30. int blockCount;
  31. PARTICLERENDERFUNCTION_TYPE renderFunction;
  32. void *dataToRenderFunction;
  33. };
  34. class CParticleEngine {
  35. public:
  36. CParticleEngine( ITileRenderer *renderer );
  37. virtual ~CParticleEngine();
  38. void createSprayType( SParticleSprayType *target,
  39. int firstBlock,
  40. int blockCount,
  41. int gravity,
  42. int fraction,
  43. int lifeTime,
  44. int lifeTimeRandom,
  45. int size,
  46. int sizeRandom,
  47. int sizeinc,
  48. int sizeincRandom,
  49. PARTICLERENDERFUNCTION_TYPE renderFunction = 0,
  50. void *dataToRenderFunction = 0,
  51. int angle = 0,
  52. int angleRandom = 0,
  53. int angleinc= 0,
  54. int angleincRandom=0,
  55. int type = 0);
  56. void spray( int count,
  57. int x, int y, int posrandom,
  58. int dx, int dy, int dirrandom,
  59. unsigned int userData,
  60. SParticleSprayType *spray );
  61. void run( int fixedFrameTime16Bit );
  62. void draw();
  63. protected:
  64. ITileRenderer *m_renderer;
  65. int m_cp;
  66. SParticle m_particles[ MAX_PARTICLES ];
  67. };
  68. #endif