Mail Archives: djgpp/1999/02/23/08:07:39
Clifford Roche writes:
> And I am writing a game that requires the program to know where on the
> screen the mouse is clickiong. There will be an image loaded onto the
> screen, and by clicking on different parts you goto different places....
> but how do I get the conputer to recognize where the mouse is clicking
> (in less than 10000 lines of source) .
I don't understand the problem here: surely you can just look at the
values of mouse_x and mouse_y to see where on the screen it is? If
your problem is how to map a coordinate onto what object they clicked,
that really depends on how complex your objects are. The Allegro GUI
provides one very basic framework for this kind of thing. If you
divide your regions into boxes, it's very easy to check for a point
being in a rectangle. If the shapes are more complex, perhaps you
could use polygonal regions (see comp.graphics.algorithms FAQ for
polygonal testing algorithms). If the areas are really random kind
of shapes, maybe it would be better to just store a big lookup table
with an entry for every pixel on the screen, listing which object
is covering it.
> Also I have found that using an ESS AudioDrive card, whenever Allegro
> does an autodetect of my sound hardware it autodetects my OPL3 Adlib but
> doesn't work properly..... I am currently setting it to use my MPU401
> interface... it is much better anyway.
You always need to select the MPU driver manually, because it's
unfortunately not possible to autodetect this interface (almost all
soundcards have one, but it isn't usually connected to a real output
device).
Shawn Hargreaves.
- Raw text -