www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/01/12:59:11

Reply-To: <arfa AT clara DOT net>
From: "Arthur" <arfa AT clara DOT net>
To: "DJGPP Mailing List" <djgpp AT delorie DOT com>, <matthew DOT krause AT juno DOT com>
Subject: RE: Tiny Allegro(Mouse) Problem
Date: Sat, 1 Aug 1998 17:59:13 +0100
Message-ID: <000701bdbd6d$b5f41880$ad4e08c3@arthur>
MIME-Version: 1.0
Importance: Normal
In-Reply-To: <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.

You've got readkey() in there?!

This may help: Go to www.gameprog.com/project. View the Unsorted Project Archive and
download source3.zip. This is the menu for a game that the G'98RGT are doing, called
Ouroboros. It's perhaps a bit more complex (It spans about ten cc files), but the bit
you're looking for is in menu.cc, button.cc and button.h. BTW, all the c and cc files
have to be compiled and linked together (no problem in RHIDE). We have a makefile,
but our project's going to fast for it to be updated all the time :^)

> 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!

The Allegro homepage is at www.tatula.demon.co.uk/allegro and you'll find links to
both mailing lists there.

James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819

- Raw text -


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