Results 1 to 8 of 8

Thread: [RESOLVED] Need Help for point and click game

Threaded View

  1. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Need Help for point and click game

    Try this code:
    Code:
    Option Explicit
    
    Dim Xtarget     As Long
    Dim Ytarget     As Long
    Dim revX        As Boolean
    Dim revY        As Boolean
    Dim xReached    As Boolean
    Dim yReached    As Boolean
    
    Private Sub Form_Load()
        Timer1.Enabled = False
        Timer1.Interval = 50
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Xtarget = CLng(X)
        Ytarget = CLng(Y)
        
        If Xtarget > Shape1.Left Then
            revX = False
        Else
            revX = True
        End If
        
        If Ytarget > Shape1.Top Then
            revY = False
        Else
            revY = True
        End If
        
        Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
        If revX = False Then
            If Shape1.Left < Xtarget Then
                Shape1.Left = Shape1.Left + 50
            Else
                xReached = True
            End If
        Else
            If Xtarget < Shape1.Left Then
                Shape1.Left = Shape1.Left - 50
            Else
                xReached = True
            End If
        End If
        
        If revY = False Then
            If Shape1.Top < Ytarget Then
                Shape1.Top = Shape1.Top + 50
            Else
                yReached = True
            End If
        Else
            If Ytarget < Shape1.Top Then
                Shape1.Top = Shape1.Top - 50
            Else
                yReached = True
            End If
        End If
        
        If xReached = True And yReached = True Then
            xReached = False
            yReached = False
            Timer1.Enabled = False
        End If
    
    End Sub
    .....
    Last edited by akhileshbc; May 21st, 2010 at 01:00 AM. Reason: added some space to make it readable

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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