Definition at line 9 of file WavyPicture.h.
Public Member Functions | |
WavyPicture (const Path &file, const V2 &loc) | |
Load surface. | |
void | setWamp (float amplitude) |
void | setWperiode (float periode) |
void | setWspeed (float speed) |
virtual void | drawOn (SDL_Surface *screen) |
Blit entire surface to [x,y]. |
|
Load surface. Default is no waves. Definition at line 20 of file WavyPicture.cpp. 00021 : Picture(file, loc) 00022 { 00023 m_amp = 0; 00024 m_periode = m_surface->w; 00025 m_speed = 0; 00026 }
|
|
Blit entire surface to [x,y]. Do vertical waves with phase shift. Reimplemented from Picture. Definition at line 33 of file WavyPicture.cpp. 00034 { 00035 if (m_amp == 0) { 00036 Picture::drawOn(screen); 00037 return; 00038 } 00039 00040 //NOTE: Wamp = Wamp_in_orig/2.0 00041 //NOTE: Wspeed = 1.0/Wspd_in_orig 00042 SDL_Rect dest_rect; 00043 SDL_Rect line_rect; 00044 line_rect.w = m_surface->w; 00045 line_rect.h = 1; 00046 SDL_Rect pad; 00047 pad.h = 1; 00048 00049 float shift = TimerAgent::agent()->getCycles() * m_speed; 00050 00051 for (int py = 0; py < m_surface->h; ++py) { 00052 //NOTE: C99 has lrintf and sinf 00053 Sint16 shiftX = static_cast<Sint16>(0.5 + 00054 m_amp * sin(py / m_periode + shift)); 00055 line_rect.x = shiftX; 00056 line_rect.y = py; 00057 dest_rect.x = m_loc.getX(); 00058 dest_rect.y = m_loc.getY() + py; 00059 SDL_BlitSurface(m_surface, &line_rect, screen, &dest_rect); 00060 00061 pad.x = (shiftX < 0) ? 0 : m_surface->w - shiftX; 00062 pad.y = py; 00063 pad.w = abs(shiftX); 00064 dest_rect.x = m_loc.getX() + pad.x; 00065 dest_rect.y = m_loc.getY() + py; 00066 SDL_BlitSurface(m_surface, &pad, screen, &dest_rect); 00067 } 00068 }
|
|
Definition at line 16 of file WavyPicture.h. 00016 { m_amp = amplitude; }
|
|
Definition at line 17 of file WavyPicture.h. 00017 { m_periode = periode; }
|
|
Definition at line 18 of file WavyPicture.h. 00018 { m_speed = speed; }
|