Salve, volevo chiedervi come posso "creare una collisione", mi spiego meglio: Vorrei che quando due oggetti si tocchino si verifichi qualcosa. Vi metto il codice che nn funziona a dovere
codice:
#include <allegro.h>
int main()
{
PALETTE pal;
int a = 10;
int b = 10;
int x = 100;
int y = 100;
bool collision = false;
allegro_init();
BITMAP* ciao = create_bitmap (100, 100);
BITMAP* ball = create_bitmap (50, 50);
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 300, 300, 0, 0);
while (!key[KEY_ESC])
{
int w = b;
int z = a;
ciao = load_bitmap ("immagine.bmp", pal);
ball = load_bitmap ("immagine.bmp", pal); // scusate questa parte nn serve
masked_blit(ciao, screen, 0,0, 200, 20 , ciao->w, ciao->h);
putpixel(screen, a, b, makecol(200, 0, 0));
if (key[KEY_UP])
{
x-= 1;
}
if (key[KEY_DOWN])
{
x+= 1;
}
if (key[KEY_RIGHT])
{
y-=1;
}
if (key[KEY_LEFT])
{
y+=1;
}
if (w==y && z==x )
{
collision = true;
}
if (collision == true)
{
textout_ex(screen, font, "UDDIO", 250, 250, makecol(255, 255, 0), -1);
}
masked_blit(ciao, screen, 0,0, x, y, ciao->w, ciao->h);
rest(1);
}
return 0;
}
END_OF_MAIN()
Quale errore faccio, come faccio a fare la collisione di due oggetti. p.s mettete anche la sintassi