Pages: 1
Topic closed
There are two things which I'm really struggling on at the moment. xD They are:
1. Making the ball bounce off the paddle according to what angle it hits it at.
2. Reducing the number of lives by one when it hits the ground. (There's another platform above it of the same colour as the ground, but I just want it to bounce off it when it hits it. I'd also rather not change the colour, but there's no problem with that if it's the only way.)
If you'd like to see the project so far, let me know! I'll also acknowledge any help in the credits if I put it on the website.
Thanks for your help, it's really appreciated!
~ Confused Newbie Programmer
Offline
When you say you want the Ball to bounce off the platform depending on the angle, are you wanting the position on the platform where the ball hits to be taken into account or is simply reversing the balls movement in the y direction what you are after?
If you post what you have done so far I'll be able to take a look at your programming style and give you some helpful advice on how you can do things
If you have the platform of the same color already set up at the ground postion then you can have the condition that if the ball and this platform touch then...
~ Reduce the lives variable by one
~ Stop the ball moving
~ Place the ball back on the platform ready to start the next life
Hope thats a little more help than the last post
Edit: Removed some BBcode that didn't work and tidied up the post a little
Last edited by NeoAtVic (2011-01-11 15:15:16)
Offline
Thanks!
In reply to your first question, reversing the ball's angle in the opposite direction would be what I'm after. So that it's taking the angle the ball hits the platform at into account, and then somehow flipping it to reverse it's path when it's leaving the platform.
The bottom platform is actually part of the background, so I tried to do it using colour instead, saying "if ball is touching colour green AND if position is less than -110 Y repeat change ghost effect by 5, 20 times." That might be ok though now, I'm not sure.
Here's the project so far:
http://scratch.mit.edu/projects/DigitTheDandelion/1537012
(I changed the "change colour" block in the bottom script of the ball's programming to "change ghost", and also added a "change life by 1". It wouldn't upload the updated version though. It said it's too big. D
Definitely more helpful than the other post lol, thank you very much!
Offline
If you want the ball to bounce off the paddle, use this script:
<when green flag clicked> <forever if [touching paddle] <point in direction 180-direction> <move 5 steps> turn pick random -20 - 20 degrees <end forever if>
Offline
Oops, that was supposed to be a sad face...
Yikes, I hope I can get it up. D:
Offline
Robo_Manic:
Thanks! I tried what you said, but the ball seemed to go through the paddle and then bounce on and off it on to the ground underneath it, but it worked fine when I changed the 180 degrees to 0 degrees. Though it didn't seem to leave the paddle in the opposite direction to when it hit it. Is there any way to get it to do this?
Offline
hm... you should see the example project pong to see the scripts you might need...
Offline
Try using the Scratch sample projects, the one with the Ping Pong game. That will greatly help and clear up some of your questions, DigitTheDandelion. Also, upload your project, so we can see what's going wrong with the project. That way, we can help better. Good luck on your ping pong game!
Offline
Thank-you very much everyone. The sample pong game helped a lot.
Offline
Could someone move this to collab?
Offline
Topic closed
Pages: 1