1 /* FloboPuyo 2 * Copyright (C) 2004 3 * Florent Boudet <flobo@ios-software.com>, 4 * Jean-Christophe Hoelt <jeko@ios-software.com>, 5 * Guillaume Borios <gyom@ios-software.com> 6 * 7 * iOS Software <http://www.ios-software.com> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; either version 2 12 * of the License, or (at your option) any later version. 13 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 * 23 * 24 */ 25 26 #ifndef _PUYOANIMATIONS 27 #define _PUYOANIMATIONS 28 29 #include <stdlib.h> 30 #include <math.h> 31 #include "glSDL.h" 32 #include "IosImgProcess.h" 33 #include "PuyoGame.h" 34 35 class AnimatedPuyo; 36 37 /* Abstract Animation class */ 38 class Animation { 39 public: 40 Animation(); 41 bool isFinished() const; 42 bool isEnabled() const; 43 virtual void cycle() = 0; 44 virtual void draw(int semiMove) = 0; 45 protected: 46 bool finishedFlag; 47 bool enabled; 48 }; 49 50 /* Abstract animation class for puyos */ 51 class PuyoAnimation : public Animation{ 52 public: PuyoAnimation(AnimatedPuyo & puyo)53 PuyoAnimation(AnimatedPuyo &puyo):attachedPuyo(puyo) {} 54 protected: 55 AnimatedPuyo &attachedPuyo; 56 }; 57 58 /* Animation synchronization helper */ 59 class AnimationSynchronizer { 60 public: 61 AnimationSynchronizer(); 62 void push(); 63 void pop(); 64 bool isSynchronized(); 65 void incrementUsage(); 66 void decrementUsage(); 67 private: 68 int currentCounter; 69 int currentUsage; 70 }; 71 72 /* Neutral falling animation */ 73 class NeutralAnimation : public PuyoAnimation { 74 public: 75 NeutralAnimation(AnimatedPuyo &puyo, int delay); 76 void cycle(); 77 void draw(int semiMove); 78 private: 79 static IIM_Surface *neutral; 80 int X, Y, currentY; 81 float step; 82 int delay; 83 }; 84 85 /* Companion turning around main puyo animation */ 86 class TurningAnimation : public PuyoAnimation { 87 public: 88 TurningAnimation(AnimatedPuyo &companionPuyo, 89 int vector, bool counterclockwise); 90 void cycle(); 91 void draw(int semiMove); 92 private: 93 int X, Y, companionVector, cpt; 94 float angle; 95 float step; 96 IIM_Surface *targetSurface; 97 bool counterclockwise; 98 }; 99 100 /* Puyo falling and bouncing animation */ 101 class FallingAnimation : public PuyoAnimation { 102 public: 103 FallingAnimation(AnimatedPuyo &puyo, 104 int originY, int xOffset, int yOffset, int step); 105 void cycle(); 106 void draw(int semiMove); 107 private: 108 int xOffset, yOffset, step; 109 int X, Y; 110 int bouncing; 111 IIM_Surface *puyoFace; 112 static const int BOUNCING_OFFSET_NUM; 113 static const int BOUNCING_OFFSET[]; 114 }; 115 116 /* Puyo exploding and vanishing animation */ 117 class VanishAnimation : public PuyoAnimation { 118 public: 119 VanishAnimation(AnimatedPuyo &puyo, int delay, int xOffset, int yOffset, AnimationSynchronizer *synchronizer); 120 virtual ~VanishAnimation(); 121 void cycle(); 122 void draw(int semiMove); 123 private: 124 IIM_Surface *puyoFace; 125 int xOffset, yOffset; 126 int X, Y, iter, color; 127 AnimationSynchronizer *synchronizer; 128 bool once; 129 int delay; 130 }; 131 132 class VanishSoundAnimation : public Animation { 133 public: 134 VanishSoundAnimation(int phase, AnimationSynchronizer *synchronizer); 135 virtual ~VanishSoundAnimation(); 136 void cycle(); 137 void draw(int semiMove); 138 private: 139 int phase; 140 int step; 141 bool once; 142 AnimationSynchronizer *synchronizer; 143 }; 144 145 #endif // _PUYOANIMATIONS 146 147