aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/animation.cpp80
-rw-r--r--engines/draci/animation.h34
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