Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/objects/Tickable.h @ 715

Last change on this file since 715 was 708, checked in by rgrieder, 17 years ago
  • added Vector2, Vector3, Matrix3, ColourValue, Quaternion and String to the misc folder as header files (each of them contains #include <string> … typedef std::string String , etc.)
  • please use String from now on by including <misc/String.h"
  • removed #include <OgreVector3.h", etc. from "CoreIncludes.h" (adjusted all source files)
  • adjusted all the source files (except network, that keeps <string> for the moment) (what a mess..)
  • moved usleep hack to misc/Sleep.h
  • relative include paths for files from other root directories (like misc, network, etc.) (but it stills writes "../Orxonox.h" when in folder orxonox/objects)
  • "OgreSceneManager.h" —> <OgreSceneManager.h>
  • included OrxonoxPrereqs in every file in folder orxonox
  • moved HUD and ParticleInterface to namespace orxonox
  • removed some using namespace Ogre/std when appropriate
  • I hope I haven't forgotten important points..
File size: 2.8 KB
RevLine 
[670]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Fabian 'x3n' Landau
23 *   Co-authors:
24 *      ...
25 *
26 */
27
[496]28/*!
29    @file Tickable.h
30    @brief Definition of the Tickable interface.
31
32    The Tickable interface provides a tick(dt) function, that gets called every frame.
[640]33    float dt is the time since the last frame in seconds.
[496]34
35    Attention:
36    Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
37    parent::tick(dt) function explicit in their implementation of tick(dt) because it's a virtual function.
38*/
39
[384]40#ifndef _Tickable_H__
41#define _Tickable_H__
42
[708]43#include <OgreFrameListener.h>
44
45#include "../OrxonoxPrereqs.h"
46
[496]47#include "../core/CoreIncludes.h"
[384]48
49namespace orxonox
50{
[496]51    class TickFrameListener; // Forward declaration
[384]52
[496]53    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
[384]54    class Tickable : virtual public OrxonoxClass
55    {
56        public:
[496]57            /**
58                @brief Gets called every frame.
[640]59                @param dt The time since the last frame in seconds
[496]60            */
[384]61            virtual void tick(float dt) = 0;
62
63        protected:
[496]64            /**
65                @brief Constructor: Registers the object in the Tickable-list
66            */
[384]67            Tickable() { RegisterRootObject(Tickable); }
68    };
69
[496]70    //! The TickFrameListener calls the tick(dt) function of all Tickables every frame.
[384]71    class TickFrameListener : public Ogre::FrameListener
72    {
73        private:
[496]74            /** @brief Gets called before a frame gets rendered. */
[384]75            bool frameStarted(const Ogre::FrameEvent &evt)
76            {
[496]77                // Iterate through all Tickables and call their tick(dt) function
[646]78                for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
79                    (it++)->tick(evt.timeSinceLastFrame);
[384]80
81                return FrameListener::frameStarted(evt);
82            }
83    };
84}
85
[673]86#endif /* _Tickable_H__ */
Note: See TracBrowser for help on using the repository browser.