1 /* 2 Copyright (C) 2007, 2010 - Bit-Blot 3 4 This file is part of Aquaria. 5 6 Aquaria is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 15 See the GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 #ifndef __element__ 22 #define __element__ 23 24 #include "../BBGE/Quad.h" 25 26 class Entity; 27 28 29 enum ElementFlag 30 { 31 EF_NONE = 0, 32 EF_SOLID = 1, 33 EF_MOVABLE = 2, 34 EF_HURT = 3, 35 EF_SOLID2 = 4, 36 EF_SOLID3 = 5, 37 EF_MAX = 6 38 /* 39 EF_GLASS = 0x00000020, 40 EF_FORCEBREAK = 0x00000100, 41 EF_HURT = 0x00000200 42 */ 43 }; 44 45 struct ElementEffectData 46 { 47 ElementEffectData(); 48 49 int elementEffectType; 50 float wavyAngleOffset, wavyMagnitude, wavyLerpIn; 51 float wavyMin, wavyMax; 52 float hitPerc, effectMult; 53 bool wavyWaving, wavyFlip, touching; 54 Vector touchVel; 55 std::vector<Vector> wavy, wavySave; 56 int elementEffectIndex; // used by editor only 57 }; 58 59 class Element : public Quad 60 { 61 public: 62 Element(); 63 ~Element(); 64 void destroy(); 65 void update(float dt); 66 int templateIdx; 67 int bgLayer; 68 Element *bgLayerNext; 69 void render(); 70 ElementFlag elementFlag; 71 void fillGrid(); isElementActive()72 bool isElementActive() { return elementActive; } 73 int getElementEffectIndex(); 74 void setElementEffectByIndex(int e); setElementActive(bool v)75 void setElementActive(bool v) { elementActive = v; } 76 void doInteraction(Entity *ent, float mult, float touchWidth); 77 protected: 78 void ensureEffectData(); 79 void freeEffectData(); 80 void setGridFromWavy(); 81 ElementEffectData *eff; 82 83 void updateEffects(float dt); 84 85 bool elementActive; 86 }; 87 88 typedef std::vector<Element*> ElementContainer; 89 90 #endif 91 92