delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/17/10:19:44

Date: Sun, 17 Aug 1997 09:18:02 -0500 (CDT)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: Thomas Harte <T DOT Harte AT btinternet DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: ALLEGRO : check for Line intersecting a point . . . how?
In-Reply-To: <33f340d2.7053399@news.btinternet.com>
Message-ID: <Pine.SUN.3.95.970817091444.3388A-100000@ernie.eecs.uic.edu>
MIME-Version: 1.0

HEre is a method I use in my editors:
Let's say you have lines spaced every 32 pixels starting in location on
screen at 16. Then when you click the mouse you want to check which is the
closest line, you do it like that:
line = (mouse_x - 16) / 32;
This will actually give you a square which you clicked for the x
direction, but you use the same code for y direction and it's not hard to
modify it to check which line.
I hope that helps.


 On Thu, 14 Aug 1997, Thomas Harte wrote:

> Hi
> 
> 	I want to know in Allegro if a line I draw intersects a point I know. Is
> there a way to do this using Allegro, or should I just implement my own line
> algorithm? The reason I ask is that I am doing the level editor for my next
> project, and obviously when you try to click and drag a line it would be
> necessary for me to know which line you are attempting to click and drag . . .
> 
> 	Or, can you think of another way for me to do this? There is in theory
> no maximum number of lines on screen, although maps above a certain complexity
> probably won't be created for runtime speed reasons if nothing else.
> 
> 		-Thomas
> 


                        ,,,
                       (0 0)
   +-------------oOO----(_)-------------------+
   |                Andrew Deren              |  
   |             aderen AT eecs DOT uic DOT edu          |
   | www.eecs.uic.edu/~aderen/ader/main.html  |
   +-------------------------oOO--------------+
                       || ||
                      ooO Ooo
 


- Raw text -


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