was allegro just not meant to be used with classes, or what?![]()
okay.. so i've got a player class that has all the data for a player (x and y positions, bitmap to use, functions for walking, jumping, shooting, etc). i had it before so that the background (just a bitmap that has some backgroundish stuff on it) was loaded and displayed in the player class (that is, i would draw the player and background to the buffer, then blit the buffer to the screen). however, i decided if i was going to have enemy classes, and things like that, then i should make the redraw function just draw the character to a buffer (pass as an arguement), and then draw the background to the buffer and blit to the screen in the main program. but i can't get it to work... here's some code
any ideas what's going wrong? i made a function in main.cpp where it was passed a BITMAP* and did the same thing as the redraw() in player, and it worked fine, so it should be possible to do this..Code://*******in the player.cpp******* void player::redraw(BITMAP *Buffer) { draw_sprite(Buffer, character, xpos, ypos); //draw character } //that's really the only important part... character is a bitmap that has the character, //and xpos and ypos are pretty self explainitory(sp?). //*******in main.cpp******* BITMAP *Buffer, *bckgrnd; //these bitmaps get loaded in a setup function int main() { setup(); //initializes everything while(!key[KEY_ESC]) { clear_bitmap(Buffer); //clear buffer plr1.redraw(Buffer); //should draw the character to Buffer, but doesn't draw_sprite(Buffer, bckgrnd, 0, 0); //draw bckgrnd to Buffer blit(Buffer, screen, 0, 0, 0, 0, 640, 480); //blit to screen } return 0; }
help is appreciated.



LinkBack URL
About LinkBacks




)
