www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/31/19:45:59

From: Vic <tudor AT cam DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Tiny Allegro(Mouse) Problem
Date: Fri, 31 Jul 1998 19:37:01 -0400
Organization: Communications Accessibles Montreal, Quebec Canada
Lines: 54
Message-ID: <35C2551D.7800@cam.org>
References: <19980731 DOT 173534 DOT 3958 DOT 1 DOT matthew DOT krause AT juno DOT com>
NNTP-Posting-Host: dialup-830.hip.cam.org
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019