[SDL] Generalised BitBlit proposal

Jake Waskett jake at waskett.org
Mon Sep 19 05:20:10 PDT 2005


Hello

I've got a little problem with my first project with SDL

Theres a class "CPlayer" (short version):
 -------------------------------------------------------------------
class CPlayer {
   public:
      /* Spielerbitmap laden */
      int LoadBMP();
      /* Spieler zeichnen */
      void Draw(SDL_Surface *target);
   private:
       /* SDL_Surface für das Bitmap */
       SDL_Surface *bmp;
       /* Muss der Spieler geupdatet werden */
       bool update;
};

int CPlayer::LoadBMP() {
   bmp = SDL_LoadBMP("gfx/player.bmp");
   if (!bmp) {
        fprintf(stderr, "Bitmap konnte nicht geladen werden: %s\n",
            SDL_GetError());
        exit(4);
    }
    return 0;
}

void CPlayer::Draw(SDL_Surface *target) {
   if(update) {
      SDL_BlitSurface(bmp, 0, target, 0);
      SDL_UpdateRect(target, 0, 0, 0, 0);
   }
}
 -------------------------------------------------------------------
n
With this class i create a player named "testi". "testi" gets some
information with a konstruktor (position, update or no update, LoadBMP()
etc.).

Then i try to draw the picture with "testi.draw(screen)" but nothing
happens. The variable update hast the value true and the Surface screen
does exist.

If i do the whole thing without a class it works.
can you help me?





More information about the SDL mailing list