Originally Posted by
grudzio
Can you post code showing how you use Matrix_To_Win function?
Ok, here is part of the procedure I call it in:
Code:
Procedure Where_Mouse;
var i, a,b,c : integer;
Winx,Winy, Winx2,Winy2 : integer;
s,t : string;
begin
SetMatrix_Edge; //Sets matrix at the top left corner of the board
a:=0; b:=0; c:=0;
for i:= 1 to 4 do //to find the coordinates of a vertex around the mouse
begin
Matrix_To_Win(a,0,b, WinX,WinY); //the coordinates of the vertex we're at
Matrix_To_Win(a+1,0,b, WinX2,WinY2); //the coordinates of the 'reference' vertex (to tell direction)
if AbsR(mpos.x-WinX)>AbsR(mpos.x-WinX2) then c:=1 //if mouse is closer to vertex a+1 than a,
else c:=-1;
if not (WinX=mpos.x) then //if mouse is at that point, then don't do anything
Repeat
a += c ; //else increase or decrease Xvertex depending on position of mouse relative to vertex
Matrix_To_Win(a,0,b, WinX,WinY);
Matrix_To_Win(a+1,0,b, WinX2,WinY2);
Until ((mpos.x<WinX>=WinX2)) or ((mpos.x>=WinX)and(mpos.x <WinX2>100) ;
When grudzio asked about the procedure I call it in, I checked everything and added the last line
Code:
or (Abs(a)>100) ;
It made sense to me that the way it was would not make it an infinite loop, but because now I can write text to the screen =)) I used it to display the value of WinX and WinY for the origin
Code:
Matrix_To_Win(0,0,0, WinX,WinY);
and I got WinX = 1786941367 and WinY = -10800336608 !
So now I understand that the problem was not in the Matrix_To_Win procedure, but rather in this loop. However, it only does that because the procedure Matrix_to_Win returns such ridiculous values.
Why does it return such values?
EDIT: The code above didn't show up the way it should have...it looks like there was some bug here :scratch:
Bookmarks