1 // Key.hpp -- A key the player has to collect. 2 // Copyright (C) 2008 Nick Gasson 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 // 17 18 #ifndef INC_KEY_HPP 19 #define INC_KEY_HPP 20 21 #include "GameObjFwd.hpp" 22 #include "AnimatedImage.hpp" 23 #include "ObjectGrid.hpp" 24 25 enum ArrowColour { acBlue, acRed, acYellow, acPink, acGreen }; 26 27 class Key : public StaticObject { 28 public: 29 Key(bool active, int xpos, int ypos, ArrowColour acol); 30 31 void DrawKey(Viewport* viewport); 32 void DrawArrow(Viewport* viewport) const; 33 void DrawIcon(int offset, float minAlpha) const; 34 bool CheckCollision(Ship& ship) const; 35 Collected()36 void Collected() { active = false; } 37 38 private: 39 static const int KEY_FRAMES = 18; 40 static const int KEY_ROTATION_SPEED = 2; 41 static const int ARROW_SIZE = 32; 42 43 int rotcount; 44 float alpha; 45 bool active; 46 AnimatedImage image; 47 Image arrow; 48 49 static string KeyFileName(ArrowColour col); 50 static string ArrowFileName(ArrowColour col); 51 }; 52 53 #endif 54