Results 1 to 8 of 8

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

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    17

    Resolved [RESOLVED] Need Help for point and click game

    Hi,

    For my high school project i need to make a game and i am trying to make it point and click style, i'm am have problems making it stop at a certain location, i can make it so it go straight to were the mouse is clicked but i want it so i click and it moves there then it stops, any help well be appreciated, thanks, Nevets_rulz123



    P.S, sorry for bad spelling.....

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

    Re: Need Help for point and click game

    Welcome to the forums...

    Did you tried coding something ? If so, show us your code...

    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,...

  3. #3
    Lively Member
    Join Date
    Dec 2008
    Posts
    70

    Re: Need Help for point and click game

    You would want to use a Do loop, such as...

    Code:
    Do While x < PointClicked
        Character.Left = x + 1
    Loop
    Of course that isn't the entire solution. You'd want to check for the current position of the character to decide if you need to go backwards or forwards, up or down

  4. #4
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: Need Help for point and click game

    Check out the ,Drag & Drop Game, link below. Thi s may offer you some ideas.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    17

    Re: Need Help for point and click game

    this is my code




    Dim xpos As Integer
    Dim ypos As Integer
    Dim Xtarget As Integer
    Dim Ytarget As Integer

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    xpos = X
    ypos = Y
    If Button = 1 Then
    Xtarget = X
    Ytarget = Y
    End If
    End Sub

    Private Sub Timer1_Timer()
    Shape1.Move Xtarget
    End Sub

    Private Sub Timer2_Timer()
    Shape1.Move Xtarget
    End Sub


    this makes it appear in the clicked location however it doesn't make it go up or down for some reason.... only horizontal

    P.S, thanks for all the help

  6. #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,...

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    17

    Re: Need Help for point and click game

    Worked like a charm Thanks so much

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

    Re: Need Help for point and click game

    You're welcome...

    If the problem is solved, please make sure to mark the thread as RESOLVED (you can use the Thread Tools found at the top of this page)

    Good luck...

    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