Code: Select all
void Inventory::Draw(SDL_Surface *surface)
{
for each (Item *i in items)
{
i->setY(i->getY()+ Level::getScrollY());
i->setX(i->getX() + Level::getScrollX());
if (i->getX() < System::SCREEN_WIDTH || i->getY() < System::SCREEN_HEIGHT)
i->Draw(surface);
i->setY(i->getY() - Level::getScrollY());
i->setX(i->getX() - Level::getScrollX());
}
}
void Item::Draw(SDL_Surface *surface)
{
SDL_BlitSurface(this->surface, &srcRect, surface, &dstRect);
}
int getX() { return dstRect.x; }
int getY() { return dstRect.y; }
void setX(int x) { dstRect.x = x; }
void setY(int y) { dstRect.y = y; }
Also, when the items should scroll off the screen, because I'm walking in the other direction, they just end up at the edge of the map.
It's almost as if they refuse to become negative.
If you could help me figure this out, I would be very grateful