Here what I did. It doesn't really give intelligence to the AI but only randomizes what happens. Y is for the ball. yy is the computer paddle.
So... if (Y > 0 && Y < 100 && X > 0 && X < 100) yy =+ yy - 1;
I set the parameters up in blocks where every other block means yy =+ yy - 1.
Initially yy = Y - 25 so that its somewhat in the center of the paddle. Here are my flaws... the paddle stops at 0 and 420 (because the height of the field is 500 and the paddle is 80) so that when the ball bounces off the walls the paddle moves again when it hits its initial value which was yy = Y - 25. Also, I think when it hits the opposing blocks with nothing set to it it goes back to its initial value. So... you can see my problem. Heres my code for this part:
As you can see... its too much pointless code for an AI. But... if someone can enlighten me on how to fix my problems on my random computer movement... it would be most appreciated. But... if someone can give me an example on how to create a real AI... then it would make things just perfect!! The following is the rest of the code if needed:
Live And Let Learn.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com