   Help with a Tron-like game
  Hi all,I made a Tron-like game and I planned to make a speed bonus but I can't make the thing right... I hope you can help me :DHere's the procedure:----------------------------------------------------------------void speed1(int time){    intr_x, r_y, speed;    intpixel;    bool    picked; if (time == 0)    {   r_x  = rand()%320;    r_y  = rand()%200;    picked = FALSE;    }   time = rand()%999+1; while ((time > 490) && (time < 495) && (picked==FALSE))    {   time = 492;   rectfill(screen, r_x, r_y, r_x+2, r_y+2, 2); pixel = getpixel(screen, x1, y1);    if (pixel==2)//(x1 >= r_x) && (x1 <= r_x+2) && (y1 <= r_y) && (y1 >= r_y+2))   {  rectfill(screen, r_x, r_y, r_x, r_y, 3);  speed  = 1;  time   = 0;  picked = TRUE;   }   break;    }}----------------------------------------------------------------If anyone could help me I would be grateful.   EDIT: It's in Allegro.[edited by - reaver1 on August 4, 2003 7:26:34 AM]
  Um....what''s the problem? I''m not going to attempt to write my own Tron code around your code to see what is wrong (as for all I know it may work for me. Bugs have a tendancy not to always be caused from where the seem.) ;  I know it's long  #include <allegro.h>#include <stdio.h>#include <conio.h>intx1 = 100,    y1 = 100;intx2 = 250,    y2 = 100;intdir1, dir2;intpix1, pix2;intspeed1 = 0,    speed2 = 0;void menu(){    bool    start = FALSE; while (!key[KEY_ESC])    {   textout(screen, font, "START"  , 135, 40, 6);   textout(screen, font, "OPTIONS", 126, 50, 6);   textout(screen, font, "EXIT"   , 139, 60, 6);}}void speed_p1(int time){    intr_x, r_y;    intcount;    bool    picked; if (time == 0)    {   r_x  = rand()%320;    r_y  = rand()%200;    picked = FALSE;    }   time = rand()%999+1; while ((time > 490) && (time < 495) && (picked==FALSE))    {   time = 492;   rectfill(screen, r_x, r_y, r_x+2, r_y+2, 2);  if ((x1 >= r_x) && (x1 <= r_x+2) && (y1 <= r_y) && (y1 >= r_y+2))   {  rectfill(screen, r_x, r_y, r_x, r_y, 3);  speed1 = 1;  time   = 0;  picked = TRUE;   }   break;    }   while ((dir1 == 1) && (speed1 == 1))    {   putpixel(screen, x1, y1  , 4);   putpixel(screen, x1, y1-1, 4);   y1 -= 2;   pix1 = getpixel(screen, x1, y1-1);   break;    }}int main() {  allegro_init();  set_gfx_mode(GFX_SAFE, 320, 240, 0, 0); install_keyboard(); install_timer();  dir1 = 2; dir2 = 4;  pix1 = 0; pix2 = 0;  //menu();    while (!key[KEY_ESC])   {    //START    putpixel(screen, x1, y1, 4);    putpixel(screen, x2, y2, 1);   speed_p1(0);//KEYS    if (key[KEY_UP] && dir1 != 3)    {   dir1=1;   clear_keybuf();    }   if (key[KEY_RIGHT] && dir1 != 4)    {   dir1=2;   clear_keybuf();    }   if (key[KEY_DOWN] && dir1 != 1)    {   dir1=3;   clear_keybuf();    }   if (key[KEY_LEFT] && dir1 != 2)    {   dir1=4;   clear_keybuf();    }    //=============PLAYER 2================    if (key[KEY_W] && dir2 != 3)    {   dir2=1;   clear_keybuf();    }   if (key[KEY_D] && dir2 != 4)    {   dir2=2;   clear_keybuf();    }   if (key[KEY_S] && dir2 != 1)    {   dir2=3;   clear_keybuf();    }   if (key[KEY_A] && dir2 != 2)    {   dir2=4;   clear_keybuf();    }    //END OF KEYS    if (pix1 == 4)    {   return 0;    }    else if (pix1 == 1)    {   return 0;    }    //PLAYER 2    if (pix2 == 1)    {   return 0;    }    else if (pix2 == 4)    {   return 0;    }    //DIR P1    while ((dir1 == 1) && (speed1 == 0))    {   putpixel(screen, x1, y1, 4);   y1--;   pix1 = getpixel(screen, x1, y1);   break;    }   while (dir1 == 2)    {   putpixel(screen, x1, y1, 4);   x1++;   pix1 = getpixel(screen, x1, y1);   break;    }   while (dir1 == 3)    {   putpixel(screen, x1, y1, 4);   y1++;   pix1 = getpixel(screen, x1, y1);   break;    }   while (dir1 == 4)    {   putpixel(screen, x1, y1, 4);   x1--;   pix1 = getpixel(screen, x1, y1);   break;    }    //DIR P2    while (dir2 == 1)    {   putpixel(screen, x2, y2, 1);   y2--;   pix2 = getpixel(screen, x2, y2);   break;    }   while (dir2 == 2)    {   putpixel(screen, x2, y2, 1);   x2++;   pix2 = getpixel(screen, x2, y2);   break;    }   while (dir2 == 3)    {   putpixel(screen, x2, y2, 1);   y2++;   pix2 = getpixel(screen, x2, y2);   break;    }   while (dir2 == 4)    {   putpixel(screen, x2, y2, 1);   x2--;   pix2 = getpixel(screen, x2, y2);   break;    }   //END    rest(50);    poll_keyboard();    clear_keybuf();   }    allegro_exit();    return 0;  }END_OF_MAIN();It's the whole code.   Linux is like a Wig-Wam: no Gates, no Windows, Apache inside.   [edited by - reaver1 on August 4, 2003 10:10:16 AM] [edited by - reaver1 on August 4, 2003 10:12:30 AM];  I mean''t what''s the problem. Does it not compile right? If so, what''s the error? Otherwise, what is the unexpected behavior? ;quote:Original post by UberGeek   I mean't what's the problem. Does it not compile right? If so, what's the error? Otherwise, what is the unexpected behavior?   No, everything compiles fine and the game works but when I touch the bonus nothing happens  It was supposed to dissapear and you should move 2 pixels instead of 1. It doesn't.   EDIT: I haven't added the movement speed yet. The bonus still doesn't want to dissapear tough.   [edited by - reaver1 on August 4, 2003 10:45:40 AM]