I've just learned how to use Allegro, and i'm working on a Lightcycles game. The collision doesn't quite work though. Can anyone tell me what's going wrong?

Code:
#include <allegro.h>
#define RESX 640
#define RESY 480

int x1 = 100, y1 = 240, x2 = 500, y2 = 240;
int d1 = 4, d2 = 3;

void main() {
 allegro_init();
 set_gfx_mode(GFX_AUTODETECT_WINDOWED, RESX, RESY, 0, 0);
 set_color_depth(8);
 install_mouse();
 install_keyboard();
 BITMAP *back = create_bitmap(RESX, RESY), *player = create_bitmap(100, 100);
 BITMAP *bbuf = create_bitmap(RESX, RESY);
 PALLETE pal;
 clear_bitmap(back);
 clear_bitmap(player);
 clear_to_color(bbuf, 1);
 back = load_bmp("bg1.bmp", pal);
 while (!key[KEY_ESC]) {
  rectfill(bbuf, x1, y1, (x1 + 5), (y1 + 5), 2);
  rectfill(bbuf, x2, y2, (x2 + 5), (y2 + 5), 4);
  if (key[KEY_LEFT]) { d1 = 3; }
  if (key[KEY_RIGHT]) { d1 = 4; }
  if (key[KEY_UP]) { d1 = 1; }
  if (key[KEY_DOWN]) { d1 = 2; }
  if (key[KEY_A]) { d2 = 3; }
  if (key[KEY_D]) { d2 = 4; }
  if (key[KEY_W]) { d2 = 1; }
  if (key[KEY_S]) { d2 = 2; }
  if (d1 == 1) { 
   if (getpixel(bbuf, --y1, x1) == 1) {   
    y1--;
   } else {
    textout(bbuf, font, "Player1 Loses! D'oh!", 1, 1, 14);
   }
  }
  if (d1 == 2) { 
   if (getpixel(bbuf, ++y1, x1) == 1) {
    y1++; 
   } else {
    textout(bbuf, font, "Player1 Loses! D'oh!", 1, 1, 14);
   }
  }
  if (d1 == 3) {
   if (getpixel(bbuf, --x1, y1) == 1) { 
    x1--; 
   } else {
    textout(bbuf, font, "Player1 Loses! D'oh!", 1, 1, 14);
   }
  }
  if (d1 == 4) { 
   if (getpixel(bbuf, ++x1, y1) == 1) {
    x1++;
   } else {
    textout(bbuf, font, "Player1 Loses! D'oh!", 1, 1, 14);
   }
  }
  if (d2 == 1) { 
   if (getpixel(bbuf, --y2, x2) == 1) {
    y2--;
   } else {
    textout(bbuf, font, "Player2 Loses! D'oh!", 1, 1, 14);
   }
  }
  if (d2 == 2) { 
   if (getpixel(bbuf, ++y2, x2) == 0) {
    y2++; 
   } else {
    textout(bbuf, font, "Player2 Loses! D'oh!", 1, 1, 14);
   }
  }
  if (d2 == 3) { 
   if (getpixel(bbuf, --x2, y2) == 1) {
    x2--;
   } else {
    textout(bbuf, font, "Player2 Loses! D'oh!", 1, 1, 14);
   } 
  }
  if (d2 == 4) {
   if (getpixel(bbuf, ++x2, y2) == 1) { 
    x2++; 
   } else {
    textout(bbuf, font, "Player2 Loses! D'oh!", 1, 1, 14);
   }
  }
  rest(5);
  vsync();
  putpixel(bbuf, 200, 100, 1);
  blit(bbuf, screen, 0, 0, 0, 0, 640, 480);
 }
 allegro_exit();
}

END_OF_MAIN();
Thanks,
Valar_King