Results 1 to 4 of 4

Thread: Requires Thinking -Yonatan?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    i have been working on moving a ball (image) to certain points on the form and move it back to where it was when a mouse over is not over certain images

    FINALLY got it working ALMOST properly
    however sometimes the ball does not go to the exact point i want it to go

    you have to do a lot of mouseovers until you see this happens
    because 90% of the time it does exactly go to the given point
    but other times it goes a little off
    any one could have a look i would GREATLY appreciated thank you

    i have done EVERYTHING humanly possible to get this working and i cant, i think someone else might pick out the problem since they have not been thinking about it too much..


    2 files you need
    http://24.112.141.149/test/frmMainMenu.frm
    http://24.112.141.149/test/frmMainMenu.frx

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    I fixed it! WOO! WOO!
    Could be improved more, but I didn't work on that.
    Also in the imgXXX_MouseMove some numbers were a bit off (A difference of 5 or 10 or 20 twips, nothing to worry about) - now they're all correct values.
    By the way, kill tmrBack.
    Looks sloppy but works:
    Code:
    Option Explicit
    
    Dim Xp1, Xp2, Yp1, Yp2, destXPoint, destYpoint As Integer
    Dim XPoint As Integer
    Dim YPoint As Integer
    Dim Slope As Double
    Dim YIntercept As Double
    Dim UpDown As Boolean
    
    Private Sub CoordinateCalc()
        UpDown = (Xp1 = Xp2)
        If Not UpDown Then
            Slope = (Yp1 - Yp2) / (Xp1 - Xp2) ' Slope cannot be negative? Yes it can!
            YIntercept = Slope * Xp1 - Yp1
        End If
    End Sub
    
    Private Sub MoveBall(x1 As Integer, x2 As Integer, y1 As Integer, y2 As Integer, dest As Integer)
        If (x1 = x2) And (y1 = y2) Then Exit Sub
        Xp1 = x1
        Xp2 = x2
        Yp1 = y1
        Yp2 = y2
        destXPoint = dest
        destYpoint = Yp2
        Call CoordinateCalc
        TmrDrop.Enabled = True
    End Sub
    
    Private Sub Form_Initialize()
        XPoint = 3
        YPoint = 3
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(3, XPoint, 3, YPoint, 3)
    End Sub
    
    Private Sub imgAdministrator_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 2970, YPoint, 5505, 2970)
    End Sub
    
    Private Sub imgCapar_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 7375, YPoint, 1750, 7375)
    End Sub
    
    Private Sub imgCutSeals_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 6360, YPoint, 1230, 6360)
    End Sub
    
    Private Sub imgDispute_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 5350, YPoint, 730, 5350)
    End Sub
    
    Private Sub imgFutureDueMeters_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 1950, YPoint, 1770, 1950)
    End Sub
    
    Private Sub imgInLog_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 7375, YPoint, 3870, 7375)
    End Sub
    
    Private Sub imgInspectionCertificate_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 3960, YPoint, 5005, 3960)
    End Sub
    
    Private Sub imgMeterInformation_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 6360, YPoint, 5480, 6360)
    End Sub
    
    Private Sub imgMSOComplaints_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 1950, YPoint, 3870, 1950)
    End Sub
    
    Private Sub imgMSOMeterInformation_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 3960, YPoint, 2850, 3960)
    End Sub
    
    Private Sub imgMSONewMeters_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 2970, YPoint, 3360, 2970)
    End Sub
    
    Private Sub ImgNonConformance_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 5350, YPoint, 4980, 5350)
    End Sub
    
    Private Sub imgOpenDB_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 1950, YPoint, 6030, 1950)
    End Sub
    
    Private Sub imgOutLog_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 6360, YPoint, 3360, 6360)
    End Sub
    
    Private Sub imgOutStandingMeters_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 5350, YPoint, 2850, 5350)
    End Sub
    
    Private Sub imgOverDueMeters_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 2970, YPoint, 1240, 2970)
    End Sub
    
    Private Sub imgPresentDueMeters_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 3960, YPoint, 730, 3960)
    End Sub
    
    
    Private Sub imgScrap_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MoveBall(XPoint, 7375, YPoint, 6000, 7375)
    End Sub
    
    Private Sub TmrDrop_Timer()
    imgBall.Left = imgBall.Left + 50 * Sgn(Xp2 - Xp1) ' -50 or +0 or +50 depending on situation
    If UpDown Then
        imgBall.Top = imgBall.Top + 50 * Sgn(Yp2 - Yp1)
    Else
        imgBall.Top = imgBall.Left * Slope - YIntercept
    End If
    
    If Not UpDown Then
    Select Case Sgn(Xp2 - Xp1)
    Case -1 ' Moves backwards
        If imgBall.Left <= Xp2 Then
            imgBall.Left = Xp2
            imgBall.Top = Yp2
            TmrDrop.Enabled = False
        End If
    Case 1 ' Moves forwards
        If imgBall.Left >= Xp2 Then
            imgBall.Left = Xp2
            imgBall.Top = Yp2
            TmrDrop.Enabled = False
        End If
    End Select
    Else ' UpDown
    Select Case Sgn(Yp2 - Yp1)
    Case -1 ' Moves up
        If imgBall.Top <= Yp2 Then
            imgBall.Left = Xp2
            imgBall.Top = Yp2
            TmrDrop.Enabled = False
        End If
    Case 1 ' Moves down
        If imgBall.Top >= Yp2 Then
            imgBall.Left = Xp2
            imgBall.Top = Yp2
            TmrDrop.Enabled = False
        End If
    End Select
    End If
    End Sub
    
    Private Sub tmrPosition_Timer()
    XPoint = imgBall.Left
    YPoint = imgBall.Top
    End Sub
    Enjoy! Have a ball!

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    hehehe

    impressive but too slopy (notice its slopy, not sloppy? )

    and if ya go on one item, and go off it the ball follows the mouse.. hehe crazy
    and if you move your mouse around on the form looks like crap

    thanks for trying to help..
    but i dont know why sometimes it goes to exact point i want it to and sometimes it goes off
    EVEN i TELL it with code to go when its done moving
    like if i tell it to go to 5, 5
    and i am increming by 7

    i check like if .left > destinationX (5) in this case it would be 7 cus its incrementing by 7
    after it goes to 7 i say well if its greater then destinationX then bring it back to destinationX

    grrr this is really making me mad
    might just drop it
    stupid thing

    appreciate your help
    oh and something else.. hehe i think i am a little crazy trying to do this with vb, should do this in openGL or something....

    [Edited by kovan on 09-14-2000 at 12:32 PM]

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Remove the Form_MouseMove event.
    I don't have the ball going to the non-exact point...
    Works OK!

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