Mail Archives: djgpp/1999/12/16/16:18:27
In article <cPb64.12704$uj2 DOT 348729 AT newscontent-01 DOT sprint DOT ca>,
max133 AT chalktv DOT com says...
> for (mx==x1; mx<x2; mx++)
> {
> for (my==y1; my<y2; 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?
- Raw text -