| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "PosterScroller.h" |
| 10 |
|
| 11 |
#include "Picture.h" |
| 12 |
#include "OptionAgent.h" |
| 13 |
#include "minmax.h" |
| 14 |
|
| 15 |
//----------------------------------------------------------------- |
| 16 |
PosterScroller::PosterScroller(const Path &picture) |
| 17 |
: PosterState(picture) |
| 18 |
{ |
| 19 |
m_shift = 0; |
| 20 |
m_screenH = 0; |
| 21 |
} |
| 22 |
//----------------------------------------------------------------- |
| 23 |
void |
| 24 |
PosterScroller::own_initState() |
| 25 |
{ |
| 26 |
m_screenH = OptionAgent::agent()->getAsInt("screen_height"); |
| 27 |
m_shift = -m_screenH + SHIFT_SPEED; |
| 28 |
} |
| 29 |
//----------------------------------------------------------------- |
| 30 |
void |
| 31 |
PosterScroller::own_updateState() |
| 32 |
{ |
| 33 |
int maxShift = min(m_shift, m_bg->getH() - m_screenH/3); |
| 34 |
|
| 35 |
m_bg->setLoc(V2(0, -maxShift)); |
| 36 |
m_shift += SHIFT_SPEED; |
| 37 |
if (m_shift > m_bg->getH()) { |
| 38 |
quitState(); |
| 39 |
} |
| 40 |
} |
| 41 |
|