Mail Archives: djgpp/1998/07/31/19:45:59
matthew DOT krause AT juno DOT com wrote:
> The code compiles fine, but, when run, I must put the cursor over the
> box, click the button, AND press a key. No where in my little sample code
> do I use the keyboard.
you got *2* readkey() calls in the code, what do they use, the sattelite
dish?
> I was wondering how to debug this code so the user
> doesn't need to use the keyboard in conjunction with the mouse.
use better code. use structured programming. what happens if the user
clicks outside of any of the 2 rectangles for example?
this code will work better. it looks bad, I just cut-n-pasted from your
code.
#include <stdlib.h> /*for good luck*/
#include "allegro.h"
int main()
{
allegro_init();
install_timer();
install_keyboard();
install_mouse();
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
set_palette(desktop_palette);
clear(screen);
rectfill(screen, 10, 10, 150, 40, 7);
rectfill(screen, 10, 300, 150, 480, 27);
show_mouse(screen);
while(1)
{
if ((mouse_x>10 && mouse_x<150) && (mouse_y>10 && mouse_y<40) &&
(mouse_b&1))
{
sound(400); /*The sound and delay are just in case I forget to look
at
the exit code*/
delay(500);
sound(0);
return 0;
}
else
if ((mouse_x>10 && mouse_x<150) && (mouse_y>300 && mouse_y<480) &&
(mouse_b&1))
{
return 55;
}
}
}
- Raw text -