[Help]Computer Logic[/solved]

Posts 1–6 of 6 · Page 1 of 1
[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.
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
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.
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.
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.
marked solved
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us