Original Post
I'm having some trouble with getting my images to draw properly. I have an Image class that gets passed the filepath, x and y position, and whether or not the image should be drawn. But if I pass it 100 for both the x and y, it draws at -100, -100. I can't see anything wrong that would make this happen, unless there is something about coordinates in SDL that is doing this. EDIT: Also, I can't use: m_rect.w = m_image.w; For some reason this works (it doesn't draw with the other code): m_rect.w = m_image.w + m_rect.w; What I don't get is how this works, shouldn't m_rect.w be some random value from memory? This has no effect on my negative coordinates problem though. [Edited by - Kenny77 on February 23, 2009 8:28:53 PM]
// Drawing the image
SDL_BlitSurface(
m_playGameButton->GetSurface(),
&m_playGameButton->GetRect(),
game->GetScreen(),
NULL);
// In the header
SDL_Rect GetRect() { return m_rect; }
// In the Image.cpp file
Image::Image(char *filepath, int x, int y, bool visible)
{
m_filepath = filepath;
m_rect.x = x;
m_rect.y = y;
m_visible = visible;
m_image = IMG_Load(filepath);
}