diff options
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; +} |
