1 // 2 // Cross-platform free Puyo-Puyo clone. 3 // Copyright (C) 2006, 2007 Emma's Software 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 2 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 // 19 #if !defined (AMOEBAX_CHAIN_LABEL_H) 20 #define AMOEBAX_CHAIN_LABEL_H 21 22 #include <stdint.h> 23 24 namespace Amoebax 25 { 26 /// 27 /// \class ChainLabel 28 /// \brief The label shown on the grid when a chain is made. 29 /// 30 class ChainLabel 31 { 32 public: 33 ChainLabel (uint8_t stepChain, int16_t x, int16_t y, 34 int16_t finalY); 35 ~ChainLabel (void); 36 37 void activate (void); 38 uint8_t getStepChain (void) const; 39 int16_t getX (void) const; 40 int16_t getY (void) const; 41 bool isActive (void) const; 42 bool isAlive (void) const; 43 void update (uint32_t elapsedTime); 44 45 private: 46 /// The speed in which the label should go up (pixels / update). 47 static const uint8_t k_Speed = 2; 48 49 /// Tells if the chain label is active and must be updated. 50 bool m_Active; 51 /// Tells if the chain label is alive or should be deleted. 52 bool m_Alive; 53 /// The final Y position the label should end at. 54 int16_t m_FinalY; 55 /// The step chain the label is showing to the user. 56 uint8_t m_StepChain; 57 /// The time the label should be allowed to live when at final Y. 58 int16_t m_TimeToLive; 59 /// The current horizontal position of the label. 60 int16_t m_X; 61 /// The current vertical position of the label. 62 int16_t m_Y; 63 }; 64 65 /// 66 /// \brief Default constructor. 67 /// 68 /// \param stepChain The step chain of the label. 69 /// \param x The X screen position where the label should be centered at. 70 /// \param y The Y screen position where the label should be centered at. 71 /// \param finalY The Y position where the label should stop to move. 72 /// 73 inline ChainLabel(uint8_t stepChain,int16_t x,int16_t y,int16_t finalY)74 ChainLabel::ChainLabel (uint8_t stepChain, int16_t x, int16_t y, 75 int16_t finalY): 76 m_Active (false), 77 m_Alive (true), 78 m_FinalY (finalY), 79 m_StepChain (stepChain), 80 m_TimeToLive (500), 81 m_X (x), 82 m_Y (y) 83 { 84 } 85 86 /// 87 /// \brief Default constructor. 88 /// 89 inline ~ChainLabel(void)90 ChainLabel::~ChainLabel (void) 91 { 92 } 93 94 /// 95 /// \brief Activates the chain label. 96 /// 97 inline void activate(void)98 ChainLabel::activate (void) 99 { 100 m_Active = true; 101 } 102 103 /// 104 /// \brief Gets the step chain. 105 /// 106 /// \return The step chain of the label. 107 /// 108 inline uint8_t getStepChain(void)109 ChainLabel::getStepChain (void) const 110 { 111 return m_StepChain; 112 } 113 114 /// 115 /// \brief Gets the X screen position. 116 /// 117 /// \return The X position of the screen where the label should be centered 118 /// at. 119 /// 120 inline int16_t getX(void)121 ChainLabel::getX (void) const 122 { 123 return m_X; 124 } 125 126 /// 127 /// \brief Gets the Y screen position. 128 /// 129 /// \return The Y position of the screen where the label should be centered 130 /// at. 131 /// 132 inline int16_t getY(void)133 ChainLabel::getY (void) const 134 { 135 return m_Y; 136 } 137 138 /// 139 /// \brief Tells if the chain label is active (i.e., should be rendered.) 140 /// 141 /// \return \a true if the chain lable is active and should be rendered, 142 /// \a false otherwise. 143 /// 144 inline bool isActive(void)145 ChainLabel::isActive (void) const 146 { 147 return m_Active; 148 } 149 150 /// 151 /// \brief Tells if the chain is alive. 152 /// 153 /// \return \a true if the chain label is alive and should not be deleted, 154 /// \a false otherwise. 155 /// 156 inline bool isAlive(void)157 ChainLabel::isAlive (void) const 158 { 159 return m_Alive; 160 } 161 } 162 163 #endif // !AMEOBAX_CHAIN_LABEL_H 164