Results 1 to 4 of 4

Thread: Any Suggestions???

  1. #1

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641

    Question

    I have the tip of a gun showing in frame1 in the
    bottom - center.
    I want a laser beam to follow the cursor from the point of the gun. Any Suggestions??

  2. #2
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Not a lot of information to go on there...

    If you calculate the offset of the tip of the gun, from the top left of the control it's in, this will give you a start point for where to place your laser beam image.

    e.g.

    If the control holding your gun image is 40 x 40 and the tip of the gun is at bottom of the control in the middle, then the start point for the laser graphic (or effect or whatever) would be

    guncontrol.left+20
    guncontrol.top+40

    This help?
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  3. #3
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Forgot to add,

    The end point for the laser would be the mouse co-ordinates...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  4. #4
    Guest
    Are you working in 2D, or 3D? If you want to work in 2D, it is simple. Use the line method to draw a Line from GunPoint.X and .Y to CursorPos.X and .Y:
    Code:
    Declare blah blah blah GetCursorPos blah()
    '// dont copy that line, use the API viewer
    Private Type POINTAPI
     X As Long
     Y As Long
    End Type
    
    Sub DrawMeLine()
     Dim CursorPos as POINTAPI
     CursorPos = GetCursorPos
     
     Canvas.Line(GunPoint.X, GunPoint.Y)-(CursorPos.X, CursorPos.Y) '//where Canvas is a valid PictureBox, Form, or (though i doubt youll use this one) Printer Object
    '//Do other drawing stuff here
    End Sub
    That will do the trick, with a bit of simple modification(The GunPoint variable, for example).

    Z.

    [edit]
    The syntax for GetCursorPos should be:
    Code:
    dim retval as long
    retval = GetCursorPos(CursorPos)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width