I'm working on Microsoft Visual Studio 2010 , trying to code a game with using Allegro.h library .
The point is that
- I'm using a buffer for drawing to buildings with draw_sprite(screen,buf1,0,0);
- After that I want to move a bitmap ball image in that screen
- when I move .bmp image , I'm using buf1 (the same buffer) again but I should clean buf1 for create a moving image
- When I do this naturally I miss all things in buffer , but I want buildings background during my game .
- How can I use two buffer in one screen ?
This is my code :
void BinaCizdir1(BITMAP *buf1){
int r;
int renk;
int say=0;
BITMAP *turuncu_beton=load_bitmap("turuncu.bmp",NULL);
BITMAP *sari_beton=load_bitmap("sari.bmp",NULL);
BITMAP *pembe_beton=load_bitmap("pink.bmp",NULL);
BITMAP *oyunu1_resmi=load_bitmap("topbu.bmp",NULL);
//Birinci oyuncunun x koordinatını belirledik.Random olarak!
int oyuncu1_y_koor=0;
int oyuncu1_x_koor1= (1+rand()%4);
if (oyuncu1_x_koor1==1){
oyuncu1_x_koor1=30;
}
if (oyuncu1_x_koor1==2){
oyuncu1_x_koor1=150;
}if (oyuncu1_x_koor1==3){
oyuncu1_x_koor1=270;
}if (oyuncu1_x_koor1==4){
oyuncu1_x_koor1=390;
}
if(kontrol==0){
renk=(rand()%3);r= (1+rand()%6)*30;
for(int x=0;x<1080;x=x+30){
for(int y=600;y>450-r;y=y-30){
if(oyuncu1_x_koor1==x){
oyuncu1_y_koor=390-r;
draw_sprite(buf1,oyunu1_resmi,oyuncu1_x_koor1,oyuncu1_y_koor);
}
if(renk==0){
draw_sprite(buf1,turuncu_beton,x,y);
}
if(renk==1){
draw_sprite(buf1,sari_beton,x,y);
}
if(renk==2){
draw_sprite(buf1,pembe_beton,x,y);
}
}
if( say%3==2 && x!=1020){
renk=(rand()%3);
r= (1+rand()%6)*30;
x=x+30;
}
say++;
/*
velocityY = velocityY +acc*dt; // updating the y component of the velocity
x = x + (velocityX*dt); // updating the x position
y = y + (velocityY*dt) + 0.5*acc*(dt*dt);// updating the y position.
rest(5);
draw_sprite(buf1,oyunu1_resmi,x,y);
*/
}
kontrol=1;
}
draw_sprite(screen,buf1,0,0);
}
This is my moving bmp image codes :
velocityY = velocityY +acc*dt; // updating the y component of the velocity
x = x + (velocityX*dt); // updating the x position
y = y + (velocityY*dt) + 0.5*acc*(dt*dt);// updating the y position.
rest(5);
draw_sprite(buf1,oyunu1_resmi,x,y);