This message was edited by Phat Nat at 2005-3-17 18:15:20
:
This message was edited by john32 at 2005-3-16 19:21:10
: ok, i can see now that if i were to involve a curve when moving the mouse from point a to point b would require a parabola of some sorts. with a parabola one would need at least four points. so how would i be able to wrte a program wher the mouse follows the path set by a random parabola containing points a and b and two other random points in between a and b. a being the staring point and b being the destination. thank you for any suggestions
:
What reason do you want the mouse to move in a curve? Does it need to follow a specific curve? Are you going to input
a and
b beforehand and have the mouse start there or just allow the mouse to continue moving through a series of parabolas?
What are you using for graphics? BGI? ASM? TPU?
I work in ASM for graphics, but here goes a try:
PROGRAM Parab;
USES Crt, Dos, Mouse, Nats;
VAR
MX, MY : Word;
MB : Byte;
T : Word;
PROCEDURE HideMouse; Assembler;
ASM
Mov Ax, $0000
Int $33
End;
PROCEDURE ShowMouse; Assembler;
ASM
Mov Ax, $0001
Int $33
End;
PROCEDURE GetMouse(VAR MouseX, MouseY : Word; VAR MouseB : Byte); Assembler;
ASM
Mov Ax, $0003
Int $33
Shr Cx, 1
Les Di, MouseX { ES:DI = @MouseX }
Mov Es:[Di], Cx
Les Di, MouseY { ES:DI = @MouseY }
Mov Es:[Di], Dx
Les Di, MouseB { ES:DI = @MouseY }
Mov Es:[Di], Bl
End;
PROCEDURE Show(X,Y : Word);
VAR
T1,T2 : Integer;
Begin
For T2 := 0 to 3 Do
For T1 := 0 to 3 Do
Mem[$A000:X+T1+(Y+T2)*320] := 15;
End;
PROCEDURE Hide(X,Y : Word);
VAR
T1,T2 : Integer;
Begin
For T2 := 0 to 3 Do
For T1 := 0 to 3 Do
Mem[$A000:X+T1+(Y+T2)*320] := 0;
End;
FUNCTION Pow(X, Y : Integer) : LongInt;
VAR Z : Byte;
Total : LongInt;
Begin
Total := X;
For Z := 2 to Abs(Y) Do
Total := Total * X;
Pow := Total;
End;
Begin
InitVGA;
DirectVideo := False;
ShowMouse;
Repeat
Hide(Mx,My);
GetMouse(MX,MY,MB);
MY := Round(Sin((MX/320*180)*Pi/180)*190);
{ T := Pow(2,(Integer(MX)-160) DIV 14);
MY := Round(T/15);}
Show(Mx,My);
Delay(3);
Until Keypressed;
HideMouse;
Readkey;
CloseGraphics;
End.
I don't know why you'd want this, but this does it (Although it's not a true "parabola", it's just half a sine wave)
There is code for a parabola (I think, school was many years ago & most of us are not mathmeticians), but this gives a start. You can do all the math part of it ;)
*Note that you can remove ShowMouse/HideMouse to remove the actual mouse path and see just the calculated path.