Cześć , w grze której zrobiłem mam 4 tła (bufor,tło gry,menu,zasady) no i ustawiony kolor ekranu. Chociaż na początku działało dobrze to w jakimś momencie kolor tła gry zmienił się nie wiem dlaczego być może usunąć z kodu clear_to_color
0
0
Musisz pokazać chociaż kawałek kodu, aby dało się namierzyć błąd i się go pozbyć.
0
#include <allegro.h>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <stdio.h>
bool kolizja(int x1,int y1,int s1,int w1,int x2,int y2,int s2,int w2)
{
if( x2<x1+s1 && x2>x1 && y2>=y1 && y2<=y1+w1 ) return true; else
if( x2<x1+s1 && x2>x1 && y2+w2>y1 && y2+w2<=y1+w1) return true; else
if( x2+s2<x1+s1 && x2+s2>x1 && y2>=y1 && y2<=y1+w1 ) return true; else
if( x2+s2<x1+s1 && x2+s2>x1 && y2+w2>y1 && y2+w2<=y1+w1) return true; else
if( x1<=x2+s2 && x1>x2 && y1>=y2 && y1<y2+w2 ) return true; else
if( x1<=x2+s2 && x1>x2 && y1+w1>=y2 && y1+w1<y2+w2) return true; else
if( x1+s1<=x2+s2 && x1+s1>x2 && y1>=y2 && y1<y2+w2 ) return true; else
if( x1+s1<=x2+s2 && x1+s1>x2 && y1+w1>=y2 && y1+w1<y2+w2) return true; else return false;
};
volatile long speed = 0;
void increment_speed()
{
speed++;
}
END_OF_FUNCTION( increment_speed );
LOCK_VARIABLE( speed );
LOCK_FUNCTION( increment_speed );
int main()
{
srand(time(NULL));
allegro_init();
install_keyboard();
set_color_depth( 8 );
set_gfx_mode( GFX_AUTODETECT, 800, 600, 0, 0 );
set_palette(default_palette);
clear_to_color( screen, makecol( 255, 255, 0 ) );
install_mouse();
install_timer();
install_int_ex( increment_speed, BPS_TO_TIMER( 200 ) );
install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, "" );
set_volume( 255, 255 );
SAMPLE * dzwiek = NULL;
BITMAP * bufor = NULL;
BITMAP * postac = NULL;
BITMAP * kwadrat1 = NULL;
BITMAP * kwadrat2 = NULL;
BITMAP * kwadrat3 = NULL;
BITMAP * kwadrat4 = NULL;
BITMAP * kwadrat5 = NULL;
BITMAP * kwadrat6 = NULL;
BITMAP * kwadrat7 = NULL;
BITMAP * kwadrat8 = NULL;
BITMAP * kwadrat9 = NULL;
BITMAP * pedzel = NULL;
BITMAP * zegar = NULL;
BITMAP * menu = NULL;
BITMAP * zasady = NULL;
BITMAP * mapa = NULL;
BITMAP * postac0 = NULL;
BITMAP * postac1 = NULL;
BITMAP * postac2 = NULL;
BITMAP * postac3 = NULL;
menu=load_bmp("menu.bmp",NULL);
postac=load_bmp("postac.bmp",NULL);
zasady=load_bmp("zasady.bmp",NULL);
mapa=load_bmp("mapa.bmp",NULL);
pedzel=load_bmp("pedzel.bmp",NULL);
zegar=load_bmp("zegar.bmp",NULL);
kwadrat1=create_bitmap(20,20);
kwadrat2=create_bitmap(20,20);
kwadrat3=create_bitmap(20,20);
kwadrat4=create_bitmap(20,20);
kwadrat5=create_bitmap(20,20);
kwadrat6=create_bitmap(20,20);
kwadrat7=create_bitmap(20,20);
kwadrat8=create_bitmap(20,20);
kwadrat9=create_bitmap(20,20);
postac0 = load_bmp( "postac0.bmp", NULL);
postac1 = load_bmp( "postac1.bmp", NULL );
postac2 = load_bmp( "postac2.bmp",NULL );
postac3 = load_bmp( "postac3.bmp", NULL );
clear_to_color(kwadrat1,makecol(255,0,0));
clear_to_color(kwadrat2,makecol(28,64,0));
clear_to_color(kwadrat3,makecol(28,64,0));
clear_to_color(kwadrat4,makecol(28,64,0));
clear_to_color(kwadrat5,makecol(28,64,0));
clear_to_color(kwadrat6,makecol(28,64,0));
clear_to_color(kwadrat7,makecol(255,0,0));
clear_to_color(kwadrat8,makecol(255,0,0));
clear_to_color(kwadrat9,makecol(255,0,0));
bufor = create_bitmap( 800, 600 );
if( !bufor )
{
set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 );
allegro_message( "Nie moge utworzyc bufora !" );
allegro_exit();
return 0;
}
if( !postac )
{
set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 );
allegro_message( "nie moge zaladowac obrazka 1 !" );
allegro_exit();
return 0;
}
int pedzel1; int pedzel_x; pedzel_x=(rand()%600)+100;
int zegar1; int zegar_x; zegar_x=(rand()%600)+100;
int licznik=0;
int max;
int menug=0;
int punkty=0;
int postac_x=400; int postac_y=525;
int liczbay;
int kwadrat1_x; int kwadrat1_y=0; kwadrat1_x=(rand()%750)+30;
int kwadrat2_x; int kwadrat2_y=0; kwadrat2_x=(rand()%750)+30;
int kwadrat3_x; int kwadrat3_y=0; kwadrat3_x=(rand()%750)+30;
int kwadrat4_x; int kwadrat4_y=0; kwadrat4_x=(rand()%750)+30;
int kwadrat5_x; int kwadrat5_y=0; kwadrat5_x=(rand()%750)+30;
int kwadrat6_x; int kwadrat6_y=0; kwadrat6_x=(rand()%750)+30;
int kwadrat7_x; int kwadrat7_y=0; kwadrat7_x=(rand()%750)+30;
int kwadrat8_x; int kwadrat8_y=0; kwadrat8_x=(rand()%750)+30;
int kwadrat9_x; int kwadrat9_y=0; kwadrat9_x=(rand()%750)+30;
int frame = 0;
while(!key[KEY_ENTER])
{
masked_blit(menu,screen,0,0,0,0,800,600);
if(key[KEY_ESC])
{ allegro_exit();
return 0;
}
if(key[KEY_SPACE]){
masked_blit(zasady,menu,0,0,0,0,800,600);
}
};
while( !key[ KEY_ESC ] )
0
Zmianiłem set_color_depth z 8 na 16 i jest dobrze. Czy mogło to byś spowodowane tym że korzystałem z 9 kolorów?