delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/31/17:43:24

From: matthew DOT krause AT juno DOT com
To: djgpp AT delorie DOT com
Date: Fri, 31 Jul 1998 15:15:24 -0400
Subject: Tiny Allegro(Mouse) Problem
Message-ID: <19980731.173534.3958.1.matthew.krause@juno.com>

I am attempting to make a graphical menu for the beginning of my program.
I have several bitmaps, each being blitted to the screen in a different
spot. When the user clicks on the bitmap, I want the program to execute
some functions, depending on which bitmap he/she had clicked on.

I had planned on using this code, replacing the colored rectangles with
bitmaps later.

#include <stdlib.h> /*for good luck*/
#include "allegro.h"

int main()
{
   allegro_init();
   install_keyboard();
   install_mouse();
   install_timer();
   set_gfx_mode(GFX_MACH64, 640, 480, 0, 0);
   set_palette(desktop_palette);
   clear(screen);
   readkey();
   rectfill(screen, 10, 10, 150, 40, 7);
   rectfill(screen, 10, 300, 150, 480, 27);
   show_mouse(screen);
   readkey();
   clear_keybuf();
   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{
   return 55;
             }
  }

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. I was wondering how to debug this code so the user
doesn't need to use the keyboard in conjunction with the mouse.

I know that this should be posted on the the allegro mailing list, but I
lost the address. If someone could send it to me, that would be great!

Thank you very much.



Matthew Krause
Orange, CT USA
" And all dared to brave unknown terrors, to do mighty deeds, to boldly
split infinitives
that no man had split before -- and thus was the empire forged"
                             --The Hichhiker's Guide to the Galaxy

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

- Raw text -


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