Hello. I'm programming a 2D game in Allegro, and I'm stuck in the very beggining. I have a main program and a class for the player. In that class, I have a function who draws a circle:
Code:
void PlayerBen::draw() {
al_draw_filled_circle(x,y,30,al_map_rgb(0,0,0));
//x and y are two variables that belong to the class
}
In my main program I have initialized some allegro stuff, and I have a circle who moves throught the screen. Everything works fine.
The problem starts when I want to create a bitmap variable to change the primitive circle for something else. I created, inside of the class, a variable ALLEGRO_BITMAP *bitmap; and I changed the code in the function draw for that:
Code:
void PlayerBen::draw() {
al_draw_bitmap(bitmap,x,y,0);
}
Well, the problem could be the way I inicialize the *bitmap variable. This is the constructor of the class:
Code:
PlayerBen::PlayerBen(int Vidas, int Speed, int X, int Y,ALLEGRO_BITMAP *Bitmap) {
vidas= Vidas;
speed= Speed;
x= X;
y= Y;
bitmap= Bitmap;
}
The parameter *Bitmap is correctly inicialized in the main program. I also draw that bitmap in the main program with the same order that I use inside my class,just for testing, and it works. But when I call the function draw, the program crash. What's happening here?
I tried to be as specific as I could, to make things easier if anyone wants to help, or ask something. Thank you in advance for the help.