Computer Science Canada Help me with my pong game |
Author: | shoobyman [ Mon Jan 16, 2006 9:22 am ] | ||
Post subject: | Help me with my pong game | ||
Hey, i need help with my program cuz this is my final exam! I need to make the ball bounce of the both platforms but i cant pick the right code :/ . PLS help! ty...
|
Author: | Albrecd [ Mon Jan 16, 2006 10:06 am ] | ||||||
Post subject: | |||||||
Quote:
First of all, you can do this much more simply by using:
(It means the same thing) Second of all, why do you have a mousewhere? You don't use it... And third of all, in order to make the ball bounce, you need to put something along the lines of:
Then do the same for the other paddle. Note that when I said < 120, you could put = 120 or something else to make the impact look better (or change 120 to 130 or something). The reason I put < 120 is that, since the ball does not move one pixel each frame, it will not nessessarily appear at 120 Y. (And Fourth of all... Constants should be entirely capitals... Ex: BALLRAD... but that's just me being picky...) |
Author: | Delos [ Mon Jan 16, 2006 2:53 pm ] |
Post subject: | |
Albrecd wrote: (And Fourth of all... Constants should be entirely capitals... Ex: BALLRAD... but that's just me being picky...)
Eh? No, that's likely just your teacher's own paradigm. No such rule, perhaps a suggestion (similar to "Reserve variable names with captial first letters for Classes only"). Perhaps a way of easing legibility. But not a rule. |
Author: | shoobyman [ Tue Jan 17, 2006 8:47 am ] |
Post subject: | |
thnx a lot ![]() |
Author: | Albrecd [ Tue Jan 17, 2006 8:52 am ] |
Post subject: | |
Quote: No, that's likely just your teacher's own paradigm. No such rule
Like I said, that's just me being picky. |
Author: | shoobyman [ Tue Jan 17, 2006 9:38 am ] | ||
Post subject: | |||
Dont get why it doesnt bounce and shakes every time? I thought i got the coordinated right but still... PLS help again ![]()
|
Author: | pavol [ Tue Jan 17, 2006 1:40 pm ] | ||||
Post subject: | |||||
first, i think that you shouldn't have : if...elsif...elsif etc. because this way only one of the conditions may be true, so put each of the conditions in a seperate if statement. second, your collision detection for the paddle looks wrong. you have
you should have something like:
do that for the other paddle as well and it should help at least a bit |
Author: | Clayton [ Tue Jan 17, 2006 10:38 pm ] | ||
Post subject: | |||
i got your ball to bounce properly now you have to figure it out your self, u should have something like this
something like that eliminates the really weird jumpy movement of the ball, but you need to figure out how to bounce off of the paddle |