diff options
author | Denis Kasak | 2009-07-03 17:50:22 +0000 |
---|---|---|
committer | Denis Kasak | 2009-07-03 17:50:22 +0000 |
commit | c178409b56990297e7521b072fda1d537b067b4c (patch) | |
tree | 52891afebee4a00c088aec8ef052f93b47af1c24 /engines | |
parent | 90e6ff9d8a2dab45ddaba2713831d47264493fa0 (diff) | |
download | scummvm-rg350-c178409b56990297e7521b072fda1d537b067b4c.tar.gz scummvm-rg350-c178409b56990297e7521b072fda1d537b067b4c.tar.bz2 scummvm-rg350-c178409b56990297e7521b072fda1d537b067b4c.zip |
Implemented beginning of the animation engine.
svn-id: r42068
Diffstat (limited to 'engines')
-rw-r--r-- | engines/draci/animation.cpp | 80 | ||||
-rw-r--r-- | engines/draci/animation.h | 34 |
2 files changed, 114 insertions, 0 deletions
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index 0aa9c14b8a..c074deb867 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -23,7 +23,87 @@ * */ +#include "draci/draci.h" +#include "draci/animation.h" + namespace Draci { +void Animation::addAnimation(uint id, uint z) { + + AnimObj *obj = new AnimObj(); + obj->_id = id; + obj->_z = z; + obj->_currentFrame = 0; + + insertAnimation(*obj); +} + +Common::List<AnimObj>::iterator Animation::getAnimation(uint id) { + + Common::List<AnimObj>::iterator it; + + for (it = _animObjects.begin(); it != _animObjects.end(); ++it) { + if (it->_id == id) { + return it; + } + } + + return _animObjects.end(); +} + +void Animation::insertAnimation(AnimObj &animObj) { + + Common::List<AnimObj>::iterator it; + + for (it = _animObjects.begin(); it != _animObjects.end(); ++it) { + if (animObj._z < it->_z) + break; + } + + _animObjects.insert(it, animObj); +} + +void Animation::addFrame(uint id, Drawable *frame) { + + Common::List<AnimObj>::iterator it = getAnimation(id); + + it->_frames.push_back(frame); +} + +void Animation::addOverlay(Drawable *overlay, uint z) { + AnimObj *obj = new AnimObj(); + obj->_id = kOverlayImage; + obj->_z = z; + obj->_currentFrame = 0; + obj->_frames.push_back(overlay); + + insertAnimation(*obj); +} + +void Animation::drawScene(Surface *surf) { + + Common::List<AnimObj>::iterator it; + + for (it = _animObjects.begin(); it != _animObjects.end(); ++it) { + if(it->_id == kOverlayImage) { + it->_frames[it->_currentFrame]->draw(surf, false); + } + else { + it->_frames[it->_currentFrame]->draw(surf, true); + } + } +} + +void Animation::deleteAnimation(uint id) { + + Common::List<AnimObj>::iterator it = getAnimation(id); + + _animObjects.erase(it); +} + +void Animation::deleteAll() { + + _animObjects.clear(); } +} diff --git a/engines/draci/animation.h b/engines/draci/animation.h index 85973aea19..8f4cc8e324 100644 --- a/engines/draci/animation.h +++ b/engines/draci/animation.h @@ -26,8 +26,42 @@ #ifndef DRACI_ANIMATION_H #define DRACI_ANIMATION_H +#include "draci/sprite.h" + namespace Draci { +enum { kOverlayImage = -1 }; + +class DraciEngine; + +struct AnimObj { + uint _id; + uint _currentFrame; + uint _z; + Common::Array<Drawable*> _frames; +}; + +class Animation { + +public: + Animation(DraciEngine *vm) : _vm(vm) {}; + + void addAnimation(uint id, uint z = 0); + void addFrame(uint id, Drawable *frame); + void addOverlay(Drawable *overlay, uint z = 0); + void deleteAnimation(uint id); + void deleteAll(); + void drawScene(Surface *surf); + Common::List<AnimObj>::iterator getAnimation(uint id); + +private: + + void insertAnimation(AnimObj &animObj); + + DraciEngine *_vm; + Common::List<AnimObj> _animObjects; +}; + } #endif // DRACI_ANIMATION_H |