From: locke AT mcs DOT net (Peter Johnson) Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro mouse routines... Code probs Date: Thu, 16 Dec 1999 15:07:08 -0600 Organization: BiLogic Productions Lines: 30 Message-ID: References: NNTP-Posting-Host: isr4186.urh.uiuc.edu X-Newsreader: MicroPlanet Gravity v2.12 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In article , max133 AT chalktv DOT com says... > for (mx==x1; mx { > for (my==y1; my { > if ((mouse_x==mx) && (mouse_y==my) )&& (mouse_b & 1)) > { > newgame(); > } > } > } Instead of this, why not the following: if ((mouse_x < x2) && (mouse_x > x1) && (mouse_y < y2) && (mouse_y > y1) && (mouse_b & 1)) newgame(); Looping through the entire coordinate range is wasteful. Also, a better way to do this test would be in a mouse callback instead of polling, but that's another topic entirely.. :) -- Peter Johnson locke AT mcs DOT net :Windows: Where do you want to go today? :Linux: Where do you want to go tomorrow? :FreeBSD: Are you guys coming or what?