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 _PUYOVIEW 27 #define _PUYOVIEW 28 29 #include "glSDL.h" 30 #include "PuyoGame.h" 31 #include "IosImgProcess.h" 32 #include "PuyoAnimations.h" 33 #include "AnimatedPuyo.h" 34 35 #define TSIZE 32 36 #define ASIZE 32 37 #define BSIZE 32 38 #define CSIZE 32 39 #define DSIZE 192 40 #define ESIZE 32 41 #define FSIZE 16 42 43 extern SDL_Surface *display; 44 extern IIM_Surface *image; 45 46 47 48 class PuyoView : public virtual PuyoDelegate { 49 public: 50 PuyoView(PuyoRandomSystem *attachedRandom, int xOffset, int yOffset, int nXOffset, int nYOffset); 51 void setEnemyGame(PuyoGame *enemyGame); 52 void render(); 53 void renderNeutral(); 54 void cycleAnimation(); 55 void cycleGame(); allowCycle()56 void allowCycle() { cycleAllowance++; } disallowCycle()57 void disallowCycle() { cycleAllowance--; } 58 59 void moveLeft(); 60 void moveRight(); 61 void rotateLeft(); 62 void rotateRight(); 63 64 static IIM_Surface *getSurfaceForState(PuyoState state); 65 IIM_Surface *getSurfaceForPuyo(PuyoPuyo *puyo); getAttachedGame()66 PuyoGame *getAttachedGame() const { return attachedGame; } getPainter()67 SDL_Painter & getPainter() const { return attachedPainter; } 68 getScreenCoordinateX(int X)69 int getScreenCoordinateX(int X) const { return X * TSIZE + xOffset; } getScreenCoordinateY(int Y)70 int getScreenCoordinateY(int Y) const { return Y * TSIZE + yOffset; } 71 72 // PuyoDelegate methods 73 void gameDidAddNeutral(PuyoPuyo *neutralPuyo, int neutralIndex); 74 void gameDidEndCycle(); 75 void companionDidTurn(PuyoPuyo *companionPuyo, int companionVector, bool counterclockwise); 76 void puyoDidFall(PuyoPuyo *puyo, int originX, int originY); 77 void puyoWillVanish(IosVector &puyoGroup, int groupNum, int phase); 78 void gameLost(); 79 80 private: 81 bool cycleAllowed(); 82 bool skippedCycle; 83 bool gameRunning; 84 int xOffset, yOffset; 85 int nXOffset, nYOffset; 86 AnimatedPuyoFactory attachedPuyoFactory; 87 PuyoGame *attachedGame, *enemyGame; 88 IosVector viewAnimations; 89 int cycleAllowance; 90 SDL_Painter &attachedPainter; 91 }; 92 93 #endif // _PUYOVIEW 94