Basically whenever i run the code, everything will work fine, but as soon as the cursor goes inside the SDL window, i get an error :Unhandled exception at 0x011af169 in game10.exe: 0xC0000005: Access violation writing location 0xcdcdcdcd. (visual studio 2010)
while(SDL_PollEvent(&mainEvent))
{
if(mainEvent.type == SDL_QUIT)
{
TheGame::Instance()->quit();
}
if(mainEvent.type == SDL_MOUSEMOTION)
{
m_mousePosition->setX(mainEvent.motion.x);
m_mousePosition->setY(mainEvent.motion.y);
}
Basically whenever theres mouse motion it should call the function SetX through the m_mousePosition object right?
(part of m_mousePosition's class):
class Vector2D
{
public:
Vector2D()
{
m_x = 0;
m_y = 0;
}
Vector2D(float x, float y) : m_x(x), m_y(y) {}
float getX() { return m_x; }
float getY() { return m_y; }
void setX(float x) { m_x = x; }//function being called, also the next statement to be executed when break happens
void setY(float y) { m_y = y; }//function being called
private:
float m_x;
float m_y;
};
Whenever i comment out the SetX and SetY functions, the problem stops, so i only assumed this is where the problem happened, any ideas on what could be going wrong?