Well I''m programming my own sprite class and here it is...
class Sprite
{
public:
int x; // x pos
int y; // y pos
int xv; // x velocity
int yv; // y velocity
int width; //width
int height; //height
//Function Declarations
Sprite();
Sprite(int xx, int yy, int wwidth, int hheight, int mode); // mode - set to DDSCAPS_VIDEOMEMORY or DDSCAPS_SYSTEMMEMORY
~Sprite();
Sprite& Sprite::operator=(Sprite spritecopy);
HRESULT Load_Sprite_Bitmap(char* bmpName);
HRESULT Draw_Sprite(LPDIRECTDRAWSURFACE7 dest);
//HRESULT Draw_Scaled_Sprite(Sprite sprite, int swidth, int sheight,LPDIRECTDRAWSURFACE7 dest);
HRESULT Load_Frame_Sprite(int frame, int cx, int cy, int mode); // cx,cy are absolute coords
HRESULT Animate_Sprite();
HRESULT Move_Sprite();
HRESULT Load_Animation_Sprite(int anim_index, int num_frames, int *sequence);
//HRESULT Set_Anim_Speed_Sprite(Sprite sprite,int speed);
HRESULT Set_Animation_Sprite(int anim_index);
//HRESULT Hide_Sprite(Sprite sprite);
//HRESULT Show_Sprite(Sprite sprite);
//bool Collision_Sprites(Sprite sprite1, Sprite sprite2);
private:
int curr_frame; // current animation frame
int num_frames; // total number of animation frames
int curr_animation; // index of current animation
int anim_counter; // used to time animation transitions
int anim_index; // animation element index
int anim_count_max; // number of cycles before animation
int *animations[NUM_SPRITE_FRAMES]; // animation sequences
RECT images[NUM_SPRITE_FRAMES]; //hold the blit info (the frames)
DDSURFACEDESC2 s_ddsd;
LPDIRECTDRAWSURFACE7 lpddssprite;
};
Now here''s the definition of the function taht seems to be causing some errors ...
HRESULT Load_Frame_Sprite(int frame, int cx, int cy, int mode)
{
cx = cx * (Sprite::width + 1) + 1; // !!!
cy = cy * (Sprite::height + 1) + 1;
RECT temprect;
temprect.top = cy;
temprect.left = cx;
temprect.bottom = cy + height; // - 1 ?
temprect.right = cx + width; // - 1 ?
Sprite::images[frame] = temprect;
return g_ddrval;
}
It shows these types of errors...
error C2597: illegal reference to data member ''Sprite::width'' in a static member function
error C2597: illegal reference to data member ''Sprite::height'' in a static member function
c:\eric\space\ericddlib.cpp(228) : error C2597: illegal reference to data member ''Sprite::images'' in a static member function
And it goes on like this for about 40 times... :0
Any ideas?
Thanks,
Destroyer