diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2018-07-26 21:15:59 +0200 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2018-07-26 21:15:59 +0200 |
| commit | bfdc0b9f497ef10f6687abcc55d93405c611af11 (patch) | |
| tree | 43914b2eada0bf5fb09093d61a250d4930b57a5d /Sprite.cpp | |
| parent | 853c6cddaa2713a9eb0c1f1c55e3f61592f04a46 (diff) | |
| download | pocketempires-bfdc0b9f497ef10f6687abcc55d93405c611af11.tar.gz | |
* Menu.cpp: actions for CHOICE_SINGLE_PLAYER_GAME have been moved to a new function called MainMenuSinglePlayer().
+ BaseUnit.cpp, BaseUnit.h: new _selected flag.
+ Camera.cpp, Camera.h: linear movement has been taken over quadratic movement. Also, cursor now moves if dealing with screen borders.
+ Cursor.cpp, Cursor.h: new Cursor class holds cursor X/Y information. It is meant to be contained inside a HumanPlayer object.
* Game.cpp: minor changes in casts and comments.
+ HumanPlayer.cpp: added callbacks for button release events.
* HumanPlayer.cpp, HumanPlayerBtn.cpp: button handling has been transferred from HumanPlayer.cpp to HumanPlayerBtn.cpp in order to improve modularity.
+ Sprite.cpp: sprite data was not being checked against NULL.
- Unit.cpp: drawHandler() is now executed by Player object.
Diffstat (limited to 'Sprite.cpp')
| -rw-r--r-- | Sprite.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
@@ -60,23 +60,12 @@ _y(0) /*****************************************************************//** * - * \brief Reportedly, this function updates X/Y coordinates for - * a Sprite object. + * \brief This function draws a \ref Sprite object on the screen. * - * \param x - * X position, relative to screen coordinates origin. - * - * \param y - * Y position, relative to screen coordinates origin. + * \remarks If \ref Sprite object must be followed by a \ref Camera + * object, X and Y coordinates are automatically adjusted. * *********************************************************************/ -void Sprite::setPos(const uint8_t x, const uint8_t y) -{ - /* Update coords according to input parameters. */ - _x = x; - _y = y; -} - void Sprite::draw(void) { gb.display.setColor(_colour, WHITE); @@ -86,10 +75,36 @@ void Sprite::draw(void) const uint8_t x = _followCam ? _cam->getX(_x) : _x; const uint8_t y = _followCam ? _cam->getY(_y) : _y; - gb.display.drawBitmap(x, y, _pu8SprData); + if (_pu8SprData != NULL) + { + gb.display.drawBitmap(x, y, _pu8SprData); + } + else + { + /* Undefined sprite data. */ + } } else { /* Error: uninitialized camera. */ } } + +/*****************************************************************//** + * + * \brief Reportedly, this function updates X/Y coordinates for + * a Sprite object. + * + * \param x + * X position, relative to screen coordinates origin. + * + * \param y + * Y position, relative to screen coordinates origin. + * + *********************************************************************/ +void Sprite::setPos(const uint8_t x, const uint8_t y) +{ + /* Update coords according to input parameters. */ + _x = x; + _y = y; +} |
