I have this code for a class called Character, If I initialize a character object my program breaks ( by calling constructor) ... but If i comment out the member function cut_sheet() then my program works as intended.
any idea?
Code:
Character::Character()
{
sheet_file = "sprites.png";
cut_sheet();
dir = DOWN;
frame = 0;
velocity_x = 0;
velocity_y = 0;
}
void Character::cut_sheet()
{
for(int i=0;i<sizeof(ani_up)/sizeof(SDL_Rect*);++i)
{
ani_up[i].x = 55 + i*40;
ani_up[i].y = 320;
ani_up[i].w = 20;
ani_up[i].h = 30;
}
for(int i=0;i<sizeof(ani_down)/sizeof(SDL_Rect*);++i)
{
ani_down[i].x = 55 + i*40;
ani_down[i].y = 360;
ani_down[i].w = 20;
ani_down[i].h = 30;
}
for(int i=0;i<sizeof(ani_left)/sizeof(SDL_Rect*);++i)
{
ani_left[i].x = 55 + i*40;
ani_left[i].y = 400;
ani_left[i].w = 20;
ani_left[i].h = 30;
}
for(int i=0;i<sizeof(ani_right)/sizeof(SDL_Rect*);++i)
{
ani_right[i].x = 55 + i*40;
ani_right[i].y = 440;
ani_right[i].w = 20;
ani_right[i].h = 30;
}
}
And I am initializing it something like this in another file
Code:
Character *unit = new Character();