Computer Science Canada

Wondering about collision movement directions wih a soccer game...

Author:  Mark0213 [ Wed Dec 07, 2011 8:36 pm ]
Post subject:  Wondering about collision movement directions wih a soccer game...

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
Hello, I was just wondering how collision coding works, i know the basics, but say you have a pad at the right side of the screen, you set coordinates of the box, with a color at the right side of the screen
then, when the ball hits the top of the pad it moves up right, and if it hits the down part, moves down right, other wise it moves straight back, Please notify me if someone can help with this
situation. I got the code for the pad the background, and the ball, but when the ball hits the pad it always moves back straight which makes the soccer frenzy game pretty useless, itll just
keep bouncing back and forth, which noone will win, i also set the ordinal values for both players to navigate their pads on either side of the screen, up and down, my only problem is the collision effect

What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>

Author:  programmer1337 [ Wed Dec 07, 2011 8:38 pm ]
Post subject:  Re: Wondering about collision movement directions wih a soccer game...

l2 put code in the code field please no one will answer your question like this

Author:  Mark0213 [ Wed Dec 07, 2011 8:41 pm ]
Post subject:  RE:Wondering about collision movement directions wih a soccer game...

Alright i will thanks

Author:  Insectoid [ Wed Dec 07, 2011 9:31 pm ]
Post subject:  RE:Wondering about collision movement directions wih a soccer game...

Pretend every paddle is actually 3 paddles side-by-side. If it hits the middle paddle, it goes straight. If it hits the top paddle, it goes up. If it hits the bottom paddle, it goes down.

You don't actually need 3 paddles. We're pretending. How can you tell if the ball hits the middle of the paddle? The bottom? The top? The same way you would if there were 3 paddles, except instead of paddle1y, paddle2y, etc, you just have paddleY, paddleY+5 (for example), and paddleY+10. There's your 3 pretend paddles.


: