/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program 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 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ /*! \file animation.h A Set of functions to animate some floats inside of an Object */ #ifndef _ANIMATION_H #define _ANIMATION_H // FORWARD DEFINITION template class tList; enum ANIM_FUNCTION {ANIM_LINEAR }; class Anim { protected: Anim(); static tList* animatorList; }; //! A Class to handle some animation for single floated values. template class Animation : public Anim { public: Animation(); virtual ~Animation(); void setFuncToAnim(T* object, void (T::*animFunc)(float)); void setAnimFunc(); void setValue(float value); void tick(float time); private: void (T::*animFunc)(float); float value; T* object; }; /** \brief standard constructor */ template Animation::Animation () { this->value = 0.0; } /** \brief standard deconstructor */ template Animation::~Animation () { // delete what has to be deleted here } template void Animation::setFuncToAnim(T* object, void (T::*animFunc)(float)) { this->object = object; this->animFunc = animFunc; } template void Animation::setValue(float value) { this->value = value; (object->*(animFunc))(value); } template void Animation::tick(float time) { setValue(value+time/1000); if (value >1) setValue (0); } #endif /* _ANIMATION_H */