diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-06 23:48:15 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-06 23:51:40 +0100 |
commit | 84cfc5ac9929d2190d9fb19fa411b72d90bb2185 (patch) | |
tree | a380ec780ec1efa2d8afe0272620a3c5f821db44 /src | |
parent | 3b7d0af6f0c61e1087838c14519e099dbbe47ec2 (diff) | |
download | mana-84cfc5ac9929d2190d9fb19fa411b72d90bb2185.tar.gz mana-84cfc5ac9929d2190d9fb19fa411b72d90bb2185.tar.bz2 mana-84cfc5ac9929d2190d9fb19fa411b72d90bb2185.tar.xz mana-84cfc5ac9929d2190d9fb19fa411b72d90bb2185.zip |
Some code formatting
Diffstat (limited to 'src')
-rw-r--r-- | src/animatedsprite.cpp | 57 |
1 files changed, 12 insertions, 45 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 840fb1e8..203a82af 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -56,7 +56,8 @@ AnimatedSprite *AnimatedSprite::load(const std::string& filename, int variant) { ResourceManager *resman = ResourceManager::getInstance(); SpriteDef *s = resman->getSprite(filename, variant); - if (!s) return NULL; + if (!s) + return NULL; AnimatedSprite *as = new AnimatedSprite(s); s->decRef(); return as; @@ -67,22 +68,18 @@ AnimatedSprite::~AnimatedSprite() mSprite->decRef(); } -void -AnimatedSprite::reset() +void AnimatedSprite::reset() { mFrameIndex = 0; mFrameTime = 0; mLastTime = 0; } -void -AnimatedSprite::play(SpriteAction spriteAction) +void AnimatedSprite::play(SpriteAction spriteAction) { Action *action = mSprite->getAction(spriteAction); if (!action) - { return; - } mAction = action; Animation *animation = mAction->getAnimation(mDirection); @@ -96,20 +93,15 @@ AnimatedSprite::play(SpriteAction spriteAction) } } -void -AnimatedSprite::update(int time) +void AnimatedSprite::update(int time) { // Avoid freaking out at first frame or when tick_time overflows if (time < mLastTime || mLastTime == 0) - { mLastTime = time; - } // If not enough time has passed yet, do nothing if (time <= mLastTime || !mAnimation) - { return; - } unsigned int dt = time - mLastTime; mLastTime = time; @@ -121,13 +113,10 @@ AnimatedSprite::update(int time) } } -bool -AnimatedSprite::updateCurrentAnimation(unsigned int time) +bool AnimatedSprite::updateCurrentAnimation(unsigned int time) { if (!mFrame || Animation::isTerminator(*mFrame)) - { return false; - } mFrameTime += time; @@ -137,9 +126,7 @@ AnimatedSprite::updateCurrentAnimation(unsigned int time) mFrameIndex++; if (mFrameIndex == mAnimation->getLength()) - { mFrameIndex = 0; - } mFrame = mAnimation->getFrame(mFrameIndex); @@ -154,30 +141,24 @@ AnimatedSprite::updateCurrentAnimation(unsigned int time) return true; } -bool -AnimatedSprite::draw(Graphics* graphics, int posX, int posY) const +bool AnimatedSprite::draw(Graphics* graphics, int posX, int posY) const { if (!mFrame || !mFrame->image) - { return false; - } return graphics->drawImage(mFrame->image, posX + mFrame->offsetX, posY + mFrame->offsetY); } -void -AnimatedSprite::setDirection(SpriteDirection direction) +void AnimatedSprite::setDirection(SpriteDirection direction) { if (mDirection != direction) { mDirection = direction; if (!mAction) - { return; - } Animation *animation = mAction->getAnimation(mDirection); @@ -190,26 +171,12 @@ AnimatedSprite::setDirection(SpriteDirection direction) } } -int -AnimatedSprite::getWidth() const +int AnimatedSprite::getWidth() const { - if (mFrame) - { - return mFrame->image->getWidth(); - } - else { - return 0; - } + return mFrame ? mFrame->image->getWidth() : 0; } -int -AnimatedSprite::getHeight() const +int AnimatedSprite::getHeight() const { - if (mFrame) - { - return mFrame->image->getHeight(); - } - else { - return 0; - } + return mFrame ? mFrame->image->getHeight() : 0; } |