[Scummvm-cvs-logs] SF.net SVN: scummvm:[42427] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Sun Jul 12 21:32:01 CEST 2009
Revision: 42427
http://scummvm.svn.sourceforge.net/scummvm/?rev=42427&view=rev
Author: dkasak13
Date: 2009-07-12 19:32:01 +0000 (Sun, 12 Jul 2009)
Log Message:
-----------
Moved the delay mechanism from Animation to Drawable since each frame in an animation can have a different delay.
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp
scummvm/branches/gsoc2009-draci/engines/draci/animation.h
scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp 2009-07-12 19:02:08 UTC (rev 42426)
+++ scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp 2009-07-12 19:32:01 UTC (rev 42427)
@@ -33,7 +33,6 @@
_z = 0;
_playing = false;
_looping = false;
- _delay = 0;
_tick = _vm->_system->getMillis();
_currentFrame = 0;
}
@@ -52,12 +51,6 @@
looping, _id);
}
-void Animation::setDelay(uint delay) {
- _delay = delay;
- debugC(7, kDraciAnimationDebugLevel, "Setting delay to %u on animation %d",
- delay, _id);
-}
-
void Animation::nextFrame(bool force) {
// If there's only one or no frames, return
@@ -65,8 +58,9 @@
return;
Common::Rect frameRect = _frames[_currentFrame]->getRect();
+ Drawable *frame = _frames[_currentFrame];
- if (force || (_tick + _delay <= _vm->_system->getMillis())) {
+ if (force || (_tick + frame->getDelay() <= _vm->_system->getMillis())) {
// If we are at the last frame and not looping, stop the animation
// The animation is also restarted to frame zero
if ((_currentFrame == getFramesNum() - 1) && !_looping) {
@@ -75,13 +69,14 @@
} else {
_vm->_screen->getSurface()->markDirtyRect(frameRect);
_currentFrame = nextFrameNum();
- _tick += _delay;
+ _tick += frame->getDelay();
}
}
debugC(6, kDraciAnimationDebugLevel,
"anim=%d tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d",
- _id, _tick, _delay, _tick + _delay, _vm->_system->getMillis(), _currentFrame, _frames.size());
+ _id, _tick, frame->getDelay(), _tick + frame->getDelay(), _vm->_system->getMillis(),
+ _currentFrame, _frames.size());
}
uint Animation::nextFrameNum() {
Modified: scummvm/branches/gsoc2009-draci/engines/draci/animation.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/animation.h 2009-07-12 19:02:08 UTC (rev 42426)
+++ scummvm/branches/gsoc2009-draci/engines/draci/animation.h 2009-07-12 19:32:01 UTC (rev 42427)
@@ -46,8 +46,6 @@
void setID(int id);
int getID();
- void setDelay(uint delay);
-
void nextFrame(bool force = false);
void drawFrame(Surface *surface);
@@ -68,7 +66,6 @@
int _id;
uint _currentFrame;
uint _z;
- uint _delay;
uint _tick;
bool _playing;
bool _looping;
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-12 19:02:08 UTC (rev 42426)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-12 19:32:01 UTC (rev 42427)
@@ -217,7 +217,9 @@
animationReader.readByte(); // Relative field, not used
Animation *anim = _vm->_anims->addAnimation(animNum, z, false);
-
+
+ anim->setLooping(cyclic);
+
for (uint i = 0; i < numFrames; ++i) {
uint spriteNum = animationReader.readUint16LE() - 1;
int x = animationReader.readSint16LE();
@@ -229,8 +231,6 @@
uint freq = animationReader.readUint16LE();
uint delay = animationReader.readUint16LE();
- anim->setDelay(delay * 10);
-
BAFile *spriteFile = _vm->_spritesArchive->getFile(spriteNum);
Sprite *sp = new Sprite(spriteFile->_data, spriteFile->_length, x, y, true);
@@ -238,7 +238,7 @@
if (mirror)
sp->setMirrorOn();
- anim->setLooping(cyclic);
+ sp->setDelay(delay * 10);
anim->addFrame(sp);
}
Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp 2009-07-12 19:02:08 UTC (rev 42426)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp 2009-07-12 19:32:01 UTC (rev 42427)
@@ -61,6 +61,7 @@
_height = height;
_x = x;
_y = y;
+ _delay = 0;
_mirror = false;
@@ -83,6 +84,7 @@
_x = x;
_y = y;
+ _delay = 0;
_mirror = false;
@@ -180,6 +182,7 @@
_x = x;
_y = y;
+ _delay = 0;
_text = new byte[len];
memcpy(_text, str.c_str(), len);
Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.h 2009-07-12 19:02:08 UTC (rev 42426)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.h 2009-07-12 19:32:01 UTC (rev 42427)
@@ -49,12 +49,20 @@
virtual void setX(int x) { _x = x; }
virtual void setY(int y) { _y = y; }
+ void setDelay(int delay) { _delay = delay; }
+ int getDelay() { return _delay; }
+
virtual Common::Rect getRect() const = 0;
private:
uint16 _width; //!< Width of the sprite
uint16 _height; //!< Height of the sprite
int _x, _y; //!< Sprite coordinates
+
+ /** The time a drawable should stay on the screen
+ * before being replaced by another or deleted
+ */
+ int _delay;
};
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list