This question already has an answer here:
- 0xC0000005: Access violation reading location 0x00000008 1 answer
First-chance exception at 0x00814477 in Only time for one more.exe: 0xC0000005: Access violation reading location 0x00000008. Unhandled exception at 0x00814477 in Only time for one more.exe: 0xC0000005: Access violation reading location 0x00000008.
//I believe this has something to do with NULL and the OS but I am unsure how to fix this
GameObject::GameObject()
{
sprite = NULL;
pos.x = 0; pos.y = 0;
vel.x = 0; vel.y = 0;
framenum = 0;
numframes = 0;
}
GameObject::~GameObject()
{
if ( sprite != NULL )
SDL_FreeSurface( sprite );
}
void GameObject::LoadImage(std::string filename)
{
sprite = IMG_Load( filename.c_str() );
//clip.x = 0;
//clip.y = 0;
clip.w = sprite->w; //It breaks here
clip.h = sprite->h; // and here
}