Results 1 to 6 of 6
  1. #1
    Shark23's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Kansas
    Posts
    424
    Reputation
    10
    Thanks
    55
    My Mood
    Cool

    [Help]Computer Logic[/solved]

    Hey all,

    I'm making a VB Pong program and need some help with the computer logic. Maybe it's just because I'm tired but I don't know. I want the computer's paddle to move up and down with the ball. How would I do that? If the ball is above the paddle, the paddle needs to move up. If the ball is below the paddle, the paddle needs to move down.
    Assembly Programmer

  2. #2
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Hmmm, VB AI, woot fun

    somwhere along the lines of

    In a timer add (the time that handles the AI for the Computer opponent
    [php]
    'Let's say image 1 is the ball
    'lets say image2 is the players paddle
    'Image 3 is the Computer panel
    If image1.Location.Y > 5 And image1.Location.Y < Me.Height - 40 _
    - image2.Height Then _
    image3.Location = New Point(image3.Location.X, image1.Location.Y)

    [/php]

    So really all you are doing is checking the balls location and matching the vertical against the horizontal so they become parallel to each other


     


     


     



    The Most complete application MPGH will ever offer - 68%




  3. The Following User Says Thank You to NextGen1 For This Useful Post:

    Shark23 (05-01-2010)

  4. #3
    Shark23's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Kansas
    Posts
    424
    Reputation
    10
    Thanks
    55
    My Mood
    Cool
    Thanks NextGen. Using that, the computer moved way too quickly and it was impossible to score. I tried something else and it works fine now. Thanks a lot!

    Edit: No it isn't. I have
    Code:
            If Ball.Top > paddleComputer.Top Then
                paddleComputer.Top += 4
            End If
    
            If Ball.Top < paddleComputer.Bottom Then
                paddleComputer.Top -= 4
            End If
    but the computer really sucks and almost never scores.
    Last edited by Shark23; 05-01-2010 at 09:43 AM.
    Assembly Programmer

  5. #4
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Use random and cases

    have it where it was , basically have it where there is a radom number and if the number generated is odd, it is a perfect block, if not then it is

    image3.Location = New Point(image3.Location.X, image1.Location.Y -2) or something, this way it is not able to block, this will allow some form of random blocks, also include speed changes to the ball, making it alittle harder.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  6. #5
    Shark23's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Kansas
    Posts
    424
    Reputation
    10
    Thanks
    55
    My Mood
    Cool
    I do have speed changes. Each time you hit the ball it speeds up a bit. I got it to work. May as well release it to everyone.
    Assembly Programmer

  7. #6
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    marked solved


     


     


     



    The Most complete application MPGH will ever offer - 68%




Similar Threads

  1. [Help Request] Help me to solve this ? :#
    By josias008 in forum Combat Arms Help
    Replies: 9
    Last Post: 08-06-2011, 12:05 AM
  2. [Help]ComboBox Selections[Solved]
    By ppl2pass in forum Visual Basic Programming
    Replies: 5
    Last Post: 03-15-2010, 02:29 PM
  3. [Help]Sleep/Pause[Solved]
    By jakobkorber in forum Visual Basic Programming
    Replies: 11
    Last Post: 03-13-2010, 06:27 AM
  4. [Help] Missing Tabs [Solved]
    By zmansquared in forum Visual Basic Programming
    Replies: 18
    Last Post: 03-11-2010, 06:25 PM
  5. [Help]Custom GUI[Solved]
    By martijno0o0 in forum Visual Basic Programming
    Replies: 1
    Last Post: 03-07-2010, 06:43 AM