Computer Science Canada My pong game...some things I need help with |
Author: | Pro Programmer! [ Sat Mar 18, 2006 10:09 am ] | ||
Post subject: | My pong game...some things I need help with | ||
Okay I got the collision all down. Its old school pong. No extra touch added.
I have a few problems. My paddles can and will go off the screen. How do I make it so that it doesn't and can go only as far as maxx and 0. Now I want to start off my ball speed slower than I have it but after a certain amount of time I want it to get faster. I know how I would make it faster and all but how would I go about doing it after a certain amount of time...say every 15 seconds? Thats all my questions for now and thanx for the help! |
Author: | Pro Programmer! [ Sat Mar 18, 2006 10:12 am ] |
Post subject: | |
Forgot to add one more thing. My ball always starts off in the same place how do I make it so that it starts a bit more random? I haven't finished and I will make a menu and all and make scores and winners and everything. I just got the hard part finished first! |
Author: | Cervantes [ Sat Mar 18, 2006 10:34 am ] | ||||||||
Post subject: | |||||||||
Welcome. Glad to see you used [code ][/code ] tags. Although, they aren't that important if your code isn't indented properly. ![]()
|
Author: | Pro Programmer! [ Sat Mar 18, 2006 12:56 pm ] |
Post subject: | |
Thanx alot! |
Author: | Pro Programmer! [ Sat Mar 18, 2006 2:27 pm ] |
Post subject: | |
Wow ok I did all that and everything and I realized something...I have NO idea how the AI is going to work. I'm going to want difficulty levels ofcourse. |
Author: | Cervantes [ Sat Mar 18, 2006 2:49 pm ] |
Post subject: | |
The simplest AI for pong would be like this: If the ball is above the paddle, move the paddle up If the ball is below the paddle, move the paddle down For levels, you can speed the paddle of the movement up, though beyond a certain point it becomes impossible to beat the computer. A more advanced AI would be to try to predict where the ball will go (use some math), then move the paddle to that spot. |
Author: | Pro Programmer! [ Sun Mar 19, 2006 2:06 pm ] | ||
Post subject: | |||
Ok I have 1 more question now (sorry lol). I did the AI like you said ceraventes but now its impossible to beat. It ALWAYS gets to it. It never missed...heres my new code
|
Author: | Cervantes [ Sun Mar 19, 2006 2:35 pm ] |
Post subject: | |
Try to impliment a little bit of randomness or poor decision or hesitation into the AI. Pick a random number (Rand.Int), from 1 to 100, say. If it is a 1, move the paddle the wrong way. Therefore, 1% of the time the computer will move the wrong way. |
Author: | Bored [ Sun Mar 19, 2006 3:12 pm ] |
Post subject: | |
The problem with the formentioned aproach is that the ai can look sorta shaky if you want it to be bad enough to beat. A better approach might be to have the ai paddle move slightly slower then the ball. I'd suggest using a real value for the speed and position so that you can fine tune the speed more accuratly and if your using a ball speed of say 1 the paddle could then move at like .75 and thus be slower. |
Author: | Pro Programmer! [ Mon Mar 20, 2006 1:36 am ] |
Post subject: | |
Yea I tried that bored. That way however, the paddle misses the ball 80% of the time. I will do what you said ceraventes and thanks for the enormous amount of help! I will make it more than 1% though. Anyways when I finish I will post it on applications! |