From: "Icehot" Newsgroups: comp.os.msdos.djgpp References: Subject: Re: Allegro mouse routines... Code probs Lines: 50 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Thu, 16 Dec 1999 21:34:50 -0800 NNTP-Posting-Host: 149.99.114.83 X-Complaints-To: abuse AT sprint DOT ca X-Trace: newscontent-01.sprint.ca 945398064 149.99.114.83 (Thu, 16 Dec 1999 21:34:24 EST) NNTP-Posting-Date: Thu, 16 Dec 1999 21:34:24 EST Organization: Sprint Canada Inc. To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hehe, thanks. Code optimazation isn't one of my virtues. Oh, if you ever want to show off unoptimized code, just post and I'll give you some. -- Max AKA Icehot http://move.to/gametek -- A Great C/C++ Programming Resource --------------------------------------------------- "Don't try to be like Jackie. There is only one Jackie... Study computers instead." - Jackie Chan Peter Johnson wrote in message news:MPG DOT 12c3107b3dc38e0b9896dd AT news DOT cso DOT uiuc DOT edu... > 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?