Computer Science Canada Pong Help |
Author: | SIXAXIS [ Fri Feb 01, 2008 9:23 pm ] | ||
Post subject: | Pong Help | ||
Hi guys, I am working on a pong game and so far, so good, but there is one problem. The ball always bounces around and never counts as out. So basically I have to figure out how to program the scoring system and where the ball can't pass (where the players are). P.S. Sorry if it's messy, I'm just starting to program. Clean it up if you want.
|
Author: | syntax_error [ Fri Feb 01, 2008 9:25 pm ] |
Post subject: | Re: Pong Help |
hmmm... if the ball goes out of the screeen what is it hitting the maxx and maxy right so just have a if condition if ball is equal to maxx and maxy {blah...} right? think it through ![]() EDIT: TRY VERY HARD NOT TO USE FORK IF YOU MUST USE IT FOR MUSIC BUT THAT IS ABOUT IT[/i] |
Author: | SIXAXIS [ Fri Feb 01, 2008 9:34 pm ] |
Post subject: | Re: Pong Help |
syntax_error @ Fri Feb 01, 2008 9:25 pm wrote: hmmm... if the ball goes out of the screeen what is it hitting the maxx and maxy right so just have a if condition if
ball is equal to maxx and maxy {blah...} right? think it through ![]() EDIT: TRY VERY HARD NOT TO USE FORK IF YOU MUST USE IT FOR MUSIC BUT THAT IS ABOUT IT[/i] Oh yeah! Thanks, I wasn't thinking straight. EDIT: I just realised it wouldn't work though. Can you help me put them together or do it some other way that both processes would be together? Then I can relate and compare the different variables. I don't really know how to do more than one thing at once without different processes and forks. It seems to work good enough until I'm finished and I get the kinks out of it. |
Author: | syntax_error [ Fri Feb 01, 2008 9:41 pm ] | ||
Post subject: | Re: Pong Help | ||
SIXAXIS wrote: syntax_error @ Fri Feb 01, 2008 9:25 pm wrote: hmmm... if the ball goes out of the screeen what is it hitting the maxx and maxy right so just have a if condition if
ball is equal to maxx and maxy {blah...} right? think it through ![]() EDIT: TRY VERY HARD NOT TO USE FORK IF YOU MUST USE IT FOR MUSIC BUT THAT IS ABOUT IT[/i] Oh yeah! Thanks, I wasn't thinking straight. I don't really know how to do more than one thing at once without different processes and forks. It seems to work good enough until I'm finished and I get the kinks out of it. well to give yo uan idea how to keep calling the proc let me give you a basic view of basicly any game you can make in turing
|
Author: | ericfourfour [ Fri Feb 01, 2008 10:07 pm ] |
Post subject: | Re: Pong Help |
syntax_error @ Fri Feb 01, 2008 9:25 pm wrote: TRY VERY HARD NOT TO USE FORK IF YOU MUST USE IT FOR MUSIC BUT THAT IS ABOUT IT
The addition of PlayFileReturn, PlayFileLoop and PlayFileStop to the Music module, has eliminated the need for processes to play music. The only case in Turing where processes are required, is when the program needs to wait for a connection. Processes are used to split your program into different threads so multiple processors can do calculations simultaneously. In Turing, the average user will never need this optimization. Chances are, if you are using processes, there is an easier and more robust way of doing things. |
Author: | syntax_error [ Fri Feb 01, 2008 10:15 pm ] |
Post subject: | Re: Pong Help |
thank you ericfourfour i wasnt aware of such functions in turing guess i should look into the new modification to turing been years since i did it tho still so now i dont think there are any reasons why SIXAXIS should use fork(s) |
Author: | SIXAXIS [ Fri Feb 01, 2008 10:25 pm ] | ||
Post subject: | Re: Pong Help | ||
This is what I have so far. It's functional, but a bit glitchy. Can you guys give me some pointers for cleaning it up and making it less glitchy?
|
Author: | ericfourfour [ Fri Feb 01, 2008 10:53 pm ] |
Post subject: | Re: Pong Help |
First of all, you should get a scrap piece of paper. Write down all of the variables the players will have. Write down all of the variables the ball will use. Write down all of the controls, how they are triggered and what they do. Then design a single loop that does the following: Get User Input Do Calculations Clear Screen Draw Everything View.Update Time Delay Then you can reprogram this pong game without processes. You should only have one main loop. This is the most important thing you can do right now. |
Author: | SIXAXIS [ Sat Feb 02, 2008 9:20 am ] |
Post subject: | Re: Pong Help |
I'll do that. EDIT: Done. The scoring system is in. If you press q or escape, the program finishes. No glitches anymore. The program is clean. Thanks for all your help guys. |