MouseCurve - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

MouseCurve

john32john32 Posts: 4Member
Hello,
I was wondering if anyone knew how to get the mouse to move from point a to point b. Sounds simple enough? How can I go about making it move in a curve like motion? Any input would be greatly appreaciated, thank you.

-John32

Comments

  • john32john32 Posts: 4Member
    [b][red]This message was edited by john32 at 2005-3-16 19:21:10[/red][/b][hr]
    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
  • Phat NatPhat Nat Posts: 757Member
    [b][red]This message was edited by Phat Nat at 2005-3-17 18:15:20[/red][/b][hr]
    : [b][red]This message was edited by john32 at 2005-3-16 19:21:10[/red][/b][hr]
    : 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 [b]a[/b] and [b]b[/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:
    [code]
    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.
    [/code]

    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.

Sign In or Register to comment.