// This file is part of Dust Racing 2D. // Copyright (C) 2012 Jussi Lind // // Dust Racing 2D is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Dust Racing 2D is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Dust Racing 2D. If not, see . #ifndef STARTLIGHTS_HPP #define STARTLIGHTS_HPP #include #include #include #include #include #include #include class Race; //! Startlight model that controls the position and animation //! of the startlights. class Startlights : public QObject { Q_OBJECT public: //! Startlights animation sequence states. enum class State { Init, Appear, FirstRow, SecondRow, ThirdRow, Go, Disappear, End }; //! Constructor. Startlights(); State state() const; void setDimensions(int width, int height); const MCVector3dF & pos() const; float glowScale() const; signals: void messageRequested(QString message); void raceStarted(); void animationEnded(); public slots: void beginAnimation(); private slots: void updateAnimation(); private: typedef std::map> StateToFunctionMap; StateToFunctionMap m_stateToFunctionMap; void stateInit(); void stateAppear(); void stateFirstRow(); void stateSecondRow(); void stateThirdRow(); void stateGo(); void stateDisappear(); void stateEnd(); bool timeElapsed(int limit); State m_state; int m_counter; int m_stepsPerState; MCVector3dF m_pos; int m_width; int m_height; float m_glowScale; MCVectorAnimation m_animation; QTimer m_timer; }; #endif // STARTLIGHTS_HPP