1 /* 2 * This file is released under the GNU General Public Licence 3 * 4 * authors: 5 * Richard Ashbury <richard.asbury@btinternet.com> 6 * Jean-Christophe Hoelt <jeko@ios-software.com> 7 */ 8 9 ///////////////////////////////////////////////////////////////////////////// 10 // 11 // corona.h : Declaration of the Corona class 12 // 13 ///////////////////////////////////////////////////////////////////////////// 14 15 #ifndef __CORONA_H_ 16 #define __CORONA_H_ 17 18 #include "corona_types.h" 19 20 // presets 21 enum { 22 PRESET_CORONA = 0, 23 PRESET_BLAZE, 24 PRESET_COUNT 25 }; 26 27 // The particles 28 struct Particle 29 { 30 double x, y, xvel, yvel; 31 }; 32 33 // The background swirl 34 struct Swirl 35 { 36 double x; 37 double y; 38 double tightness; 39 double pull; 40 }; 41 42 43 ///////////////////////////////////////////////////////////////////////////// 44 // 45 // Core Class of the Corona Visual FX 46 // 47 ///////////////////////////////////////////////////////////////////////////// 48 49 class Corona 50 { 51 private: 52 int m_clrForeground; // foreground color 53 int m_nPreset; 54 55 Particle *m_particles; 56 int nbParticules; 57 58 // The off-screen buffer 59 unsigned char* m_image; 60 unsigned char* m_real_image; 61 62 int m_width; 63 int m_height; 64 int m_real_height; 65 66 Swirl m_swirl; 67 unsigned char** m_deltafield; 68 69 // Particle movement info 70 int m_swirltime; 71 Swirl m_movement; 72 73 bool m_testing; 74 bool m_silent; 75 76 // Beat detection 77 double m_avg; 78 double m_oldval; 79 int m_pos; 80 81 // Waves 82 double m_waveloop; 83 int *m_reflArray; 84 85 // Implementation functions 86 double random(double min, double max) const; 87 // void setUpPalette(); 88 void drawLine(int x0, int y0, int x1, int y1, unsigned char col); 89 void drawParticules(); 90 void drawParticulesWithShift(); 91 void blurImage(); 92 void drawReflected(); 93 94 void chooseRandomSwirl(); 95 void setPointDelta(int x, int y); 96 void applyDeltaField(bool heavy); 97 int getBeatVal(TimedLevel *tl); 98 void getAvgParticlePos(double& x, double& y) const; 99 void genReflectedWaves(double loop); 100 101 102 public: 103 Corona(); 104 ~Corona(); 105 106 bool setUpSurface(int width, int height); 107 void update(TimedLevel *pLevels); getSurface()108 unsigned char *getSurface() const { return m_real_image; } 109 getWidth()110 int getWidth() const { return m_width; } getHeight()111 int getHeight() const { return m_real_height; } 112 }; 113 114 #endif //__CORONA_H_ 115