int Sprite::getPixel(int x, int y, const Displacement &displacement) const { Common::Rect rect = getRect(displacement); int dy = y - rect.top; int dx = x - rect.left; // Calculate scaling factors double scaleX = double(rect.width()) / _width; double scaleY = double(rect.height()) / _height; int sy = scummvm_lround(dy / scaleY); int sx = scummvm_lround(dx / scaleX); if (_mirror) return _data[sy * _width + (_width - sx)]; else return _data[sy * _width + sx]; }
Common::Rect Sprite::getRect(const Displacement &displacement) const { return Common::Rect(_x + displacement.relX, _y + displacement.relY, _x + displacement.relX + scummvm_lround(_scaledWidth * displacement.extraScaleX), _y + displacement.relY + scummvm_lround(_scaledHeight * displacement.extraScaleY)); }
Displacement Animation::getCurrentFrameDisplacement() const { Displacement dis = _displacement; dis.relX += scummvm_lround(dis.extraScaleX * _shift.x); dis.relY += scummvm_lround(dis.extraScaleY * _shift.y); return dis; }