delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/11/05:01:09

From: Nicolas Blais <eletech AT netrover DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: How to get the Area of a square...
Date: Wed, 10 Jun 1998 22:05:55 -0400
Organization: Elemental Technologies
Lines: 21
Message-ID: <357F3B82.D761E6FD@netrover.com>
NNTP-Posting-Host: 198.168.87.29
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi, let's say I have a 40 by 40 pixels square (at 0,0) on the screen.  I
use Allegro for my mouse routines and I currently use a do/while loop to
see if the mouse is over this square, but it's very slow and
inefficient.  Can someone suggest me a better way with example?

Here's way I do:

do
    {
    for (int x = 0; x = 40; x++)
       {
        for (int y = 0; y = 40; y++)
            {
             if (mouse_x == x && mouse_y = y)
            outtext(screen,font,"Bla",1,1,COLOR);
             }
        }
    } while (keypressed() != 0);

Sorry for my coding habits...  Nicolas Blais

- Raw text -


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