| 1 | // Copyright 2005 by Anthony Liekens [email protected] |
| 2 | |
| 3 | #include "animations.h" |
| 4 | #include "timer.h" |
| 5 | #include "planets.h" |
| 6 | #include "coordinate.h" |
| 7 | #include "canvas.h" |
| 8 | |
| 9 | void |
| 10 | AnimationQueue::render(Uint32 time) { |
| 11 | for( iterator i = begin(); i != end(); i++ ) { |
| 12 | Animation* animation = (Animation*)( i->second ); |
| 13 | animation->render(time); |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | SonarAnimation::SonarAnimation() { |
| 18 | } |
| 19 | |
| 20 | SonarAnimation::SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle ) { |
| 21 | this->circle = circle; |
| 22 | this->planet = planet; |
| 23 | r = ( color & 0xFF0000 ) >> 16; |
| 24 | g = ( color & 0x00FF00 ) >> 8; |
| 25 | b = ( color & 0x0000FF ); |
| 26 | // this->color = color; |
| 27 | this->size = size; |
| 28 | this->startTime = startTime; |
| 29 | this->endTime = endTime; |
| 30 | } |
| 31 | |
| 32 | void |
| 33 | SonarAnimation::render(Uint32 time) { |
| 34 | if( ( time > startTime ) && ( time < endTime ) ) { |
| 35 | double percentage = (double)( time - startTime ) / ( endTime - startTime ); |
| 36 | Canvas::drawSonar(planet->getLocation(), size, percentage, r, g, b, circle); |
| 37 | } |
| 38 | } |