src/supertux/timer.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_SUPERTUX_TIMER_HPP
00018 #define HEADER_SUPERTUX_SUPERTUX_TIMER_HPP
00019 
00020 #include "supertux/globals.hpp"
00021 
00025 class Timer
00026 {
00027 public:
00028   Timer();
00029   ~Timer();
00030 
00035   void start(float period, bool cyclic = false);
00039   bool check();
00041   void stop()
00042   { start(0); }
00043 
00045   float get_period() const
00046   { return period; }
00047   float get_timeleft() const
00048   { return period - (game_time - cycle_start); }
00049   float get_timegone() const
00050   { return game_time - cycle_start; }
00051   bool started() const
00052   { return period != 0 && get_timeleft() > 0; }
00053 
00054 private:
00055   float period;
00056   float cycle_start;
00057   bool cyclic;
00058 };
00059 
00060 #endif
00061 
00062 /* EOF */

Generated on Mon Apr 14 03:38:26 2014 for SuperTux by  doxygen 1.5.1