#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Pong?

Posts: 233Member
Guys and girls,

To learn programming with DirectX 7 I'm going to make a Pong like game. But to make the computer paddle a bit easier to beat I want to implement some xtra's. To make the computer hit the ball it just follows the path of the ball. Giant gave me another option: Let the computer calc the end point and to make it easier to beat us a confusion variable. But how do I implement this? Randomly let the computer choose a number between X and Y and increase or decrease the calculated end point?

thanks,

Sand Hawk

· ·

• Posts: 64Member
I think what you are trying to do, let me get this straight before I just make a fool of myself.. You are trying to make the computer auto calculate the end point of the ball, and as well you want a confusion variable to throw the computer off. Correct?

If this is so, what you would want to do is set the calculations for where the ball is going, so the computer can follow every time. After he follows it, then you do perhaps a random between 1 and 10, if it hits lets just say 7 or 4 (use an if function) then he will miss by [Coordinates of the ball]-[X number of coordinates away]. Making X a random number will make it even more realistic, depending on the axis of the paddle you could say perhaps 3 coords away, and then he might still hit it. Am I making any sense? It will keep the computer looking a little intelligent if you just do a small number away though, that way it doesn't look like he is just being stupid. It wouldn't make sense for him to go left on the screen and the ball falling to the right (or up and down comparison).

Well let me know if I was following your drift.

: Guys and girls,
:
: To learn programming with DirectX 7 I'm going to make a Pong like game. But to make the computer paddle a bit easier to beat I want to implement some xtra's. To make the computer hit the ball it just follows the path of the ball. Giant gave me another option: Let the computer calc the end point and to make it easier to beat us a confusion variable. But how do I implement this? Randomly let the computer choose a number between X and Y and increase or decrease the calculated end point?
:
: thanks,
:
: Sand Hawk
:

· ·
• Posts: 233Member
You just said what I was thinking. I already thought out a way do this wich is exactly the same as yours. Another possibility is to change the current point of the ball with a confusion variable so the end point of the ball becomes more unpredictable for the computer. I'm gonna try both ways!

Thanks,

Sand Hawk

- Earth is 98% full. Please delete anybody you can.

· ·
• Posts: 64Member
Let me know how it turns out.

: You just said what I was thinking. I already thought out a way do this wich is exactly the same as yours. Another possibility is to change the current point of the ball with a confusion variable so the end point of the ball becomes more unpredictable for the computer. I'm gonna try both ways!
:
: Thanks,
:
: Sand Hawk
:
: - Earth is 98% full. Please delete anybody you can.
:
:

· ·