You should just pass the right parameters (ie, the surface) to the function which draws the sprite.....
That's what I would do
------------------
Dance with me......
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
You should just pass the right parameters (ie, the surface) to the function which draws the sprite.....
That's what I would do
------------------
Dance with me......
1 - DirectDraw. Just blits in DX and inits DX.
2 - Blitting. Abstraction for blitting, so its API/OS independent.
3 - Draw Queue. Makes a queue that can add/clear list of things to draw. Can draw images, text, animations, etc.
4 - Elements, like sprites and text. These can each have things like sprite->Draw(). text->Draw(). Which will create an index in the DrawQueue...
-Geoff
Well, some people will tell me I am stupid, but I would create a global instance of class DrawManager.
Define this global variable somewhere in your main.cpp or winmain.cpp or something like that like so:
DrawManager MyDrawManager;
In your main.h or winmain.h or something like that put in a:
extern DrawManager MyDrawManager;
Well, that's all. Now you have access to MyDrawManager from everywhere in your program (you will have to include main.h into the implementation file of sprite. Then you could do something like that:
.....
#include "main.h"
void Sprite: raw(long x, long y)
{
MyDrawManager.DrawSprite(this,x,y);
}
Too many global variables are shit, but a few of them are great, cause you have access to them everywhere without casting pointers around all over the time. Pointers are dangerous cause they cause a GPF when they are NULL, and checking them all the time is shit, too !!
Hope this helps.
Phillip
Now you see that the Instantiating classes needs to know details of the DisplayManager (like what buffering, unless you blit all of them EVERY frame)...so I recommend one of the following....global variable or static class memeber (IF you do not intend to support multiple monitor or video card setups)..otherwise you might need to pass the DisplayManager to each of the redraw functions...this way additional monitors can be added by just making TWO seperate Image lists...each one associated with a particular DisplayManager.
I could send you source or look at your source if you'd like.
class Game {
int score;
public:
int Give_Score(){return score;}
void Change_Score(int score1){score=score1;}
};
Then if yo need to print score jus do :
printf("WHATEVER:%s",Game.Give_Score());
and yo no how to change score
I think thatl work
- Splat
Marcus