#include <shrinkfade.hpp>
Inherits ScreenFade.
Public Member Functions | |
ShrinkFade (const Vector &point, float fade_time) | |
virtual | ~ShrinkFade () |
virtual void | update (float elapsed_time) |
gets called for once (per logical) frame. | |
virtual void | draw (DrawingContext &context) |
gets called once per frame. | |
virtual bool | done () |
returns true if the effect is completed | |
Private Attributes | |
Vector | dest |
float | fade_time |
float | accum_time |
float | speedleft |
float | speedright |
float | speedtop |
float | speedbottom |
Definition at line 26 of file shrinkfade.hpp.
ShrinkFade::ShrinkFade | ( | const Vector & | point, | |
float | fade_time | |||
) |
Definition at line 21 of file shrinkfade.cpp.
References dest, SCREEN_HEIGHT, SCREEN_WIDTH, speedbottom, speedleft, speedright, speedtop, Vector::x, and Vector::y.
00021 : 00022 dest(dest), 00023 fade_time(fade_time), 00024 accum_time(0), 00025 speedleft(), 00026 speedright(), 00027 speedtop(), 00028 speedbottom() 00029 { 00030 speedleft = dest.x / fade_time; 00031 speedright = (SCREEN_WIDTH - dest.x) / fade_time; 00032 speedtop = dest.y / fade_time; 00033 speedbottom = (SCREEN_HEIGHT - dest.y) / fade_time; 00034 }
ShrinkFade::~ShrinkFade | ( | ) | [virtual] |
void ShrinkFade::update | ( | float | elapsed_time | ) | [virtual] |
gets called for once (per logical) frame.
ScreenFades should do their state updates and logic here
Implements ScreenFade.
Definition at line 41 of file shrinkfade.cpp.
References accum_time, and fade_time.
00042 { 00043 accum_time += elapsed_time; 00044 if(accum_time > fade_time) 00045 accum_time = fade_time; 00046 }
void ShrinkFade::draw | ( | DrawingContext & | context | ) | [virtual] |
gets called once per frame.
The ScreenFade should draw itself in this function. State changes should not be done in this function, but rather in update
Implements ScreenFade.
Definition at line 49 of file shrinkfade.cpp.
References accum_time, dest, DrawingContext::draw_inverse_ellipse(), fade_time, LAYER_GUI, SCREEN_HEIGHT, and SCREEN_WIDTH.
00050 { 00051 float progress = accum_time / fade_time; 00052 context.draw_inverse_ellipse(dest, 00053 Vector(2*SCREEN_WIDTH * (1.0f - progress), 00054 2*SCREEN_HEIGHT * (1.0f - progress)), 00055 Color(0, 0, 0), LAYER_GUI+1); 00056 }
bool ShrinkFade::done | ( | ) | [virtual] |
returns true if the effect is completed
Implements ScreenFade.
Definition at line 59 of file shrinkfade.cpp.
References accum_time, and fade_time.
00060 { 00061 return accum_time >= fade_time; 00062 }
Vector ShrinkFade::dest [private] |
float ShrinkFade::fade_time [private] |
float ShrinkFade::accum_time [private] |
float ShrinkFade::speedleft [private] |
float ShrinkFade::speedright [private] |
float ShrinkFade::speedtop [private] |
float ShrinkFade::speedbottom [private] |