We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Simple pong
Page Index Toggle Pages: 1
Simple pong (Read 1022 times)
Simple pong
Jan 4th, 2010, 9:35am
 
I just made this simple game which can be seen here...

openprocessing.org/visuals/?visualID=6814
(Sorry new user here Sad)

The ball travels at a constant speed. You control the pad with your mouse. You can reset by clicking on the screen. If the ball hits the bottom of the screen you lose one life of three. Once all your lives are gone the ball becomes invisable.

I just need help with a few things.

  • How to I make the text for displaying how many lives you have left clearer?? Its almost unreadable atm.

  • And. How would I incorporate an AI at the top of the board to play as another pad which would return the ball ??



Thanks in advanced:D
Re: Simple pong
Reply #1 - Jan 5th, 2010, 5:07am
 
1) I would add more padding at the bottom of the window, so you get enough space to write the score.

2) I would make a class for the Pad object, so you can easily add another pad. AI is another challenge, though.
Re: Simple pong
Reply #2 - Jan 6th, 2010, 5:51am
 
For the AI:

It is enough to take the same X-Value for the AI-Pad as the X-value of the ball. You can add a random-value to allow for errors. You can even add a small X via random.

Greetings, Chrisir
Re: Simple pong
Reply #3 - Jan 6th, 2010, 6:45am
 
Well, it would be more realistic to add some limitation on the speed of the computer's pad, so it can try to follow the ball but might be too late...
Can also add some inertia, decelerating before stopping and moving (with acceleration) on the other direction.
Page Index Toggle Pages: 1