Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need help with Ping Pong game !
- Marek_es
-
Scratcher
7 posts
Need help with Ping Pong game !
Hello there guys. Lately i created a PONG! game on scratch, and in my opinion it looks decent (by thoughts that iam new to scratch).
The thing is, that whenever the ball gets at some speed, it just skips the racket, and it passes by. I don't have any ideas on how to solve that problem.
Right now the game is about surviving to the, let's say DEAD SPEED where the ball just goes straight for the point, no matter what.
I would like to make it work as a normal pong, thanks in advance, for the potential help =)
Oh and of course, project link is there : http://scratch.mit.edu/projects/36341064/
The thing is, that whenever the ball gets at some speed, it just skips the racket, and it passes by. I don't have any ideas on how to solve that problem.
Right now the game is about surviving to the, let's say DEAD SPEED where the ball just goes straight for the point, no matter what.
I would like to make it work as a normal pong, thanks in advance, for the potential help =)
Oh and of course, project link is there : http://scratch.mit.edu/projects/36341064/
- lbruns
-
Scratcher
500+ posts
Need help with Ping Pong game !
Hello there guys. Lately i created a PONG! game on scratch, and in my opinion it looks decent (by thoughts that iam new to scratch).
The thing is, that whenever the ball gets at some speed, it just skips the racket, and it passes by. I don't have any ideas on how to solve that problem.
Right now the game is about surviving to the, let's say DEAD SPEED where the ball just goes straight for the point, no matter what.
I would like to make it work as a normal pong, thanks in advance, for the potential help =)
Oh and of course, project link is there : http://scratch.mit.edu/projects/36341064/
If the ball is moving too fast it won't detect that it is hitting the player's racket.
- Imaginary_Numbers
-
Scratcher
42 posts
Need help with Ping Pong game !
Scratch is probably just lagging so it doesn't detect the ball is touching the racket. By “when the ball starts picking up some speed” I assume that you have a script telling the ball to start moving faster as the game goes on. My suggesting is that you add this to the script that increases speed:
set [MAX SPEED v] to [10]
then add this:
forever
if <(Speed) > (MAX SPEED) > then
forever
set [Speed v] to [10]
end
end
end
- Marek_es
-
Scratcher
7 posts
Need help with Ping Pong game !
Hello there guys. Lately i created a PONG! game on scratch, and in my opinion it looks decent (by thoughts that iam new to scratch).
The thing is, that whenever the ball gets at some speed, it just skips the racket, and it passes by. I don't have any ideas on how to solve that problem.
Right now the game is about surviving to the, let's say DEAD SPEED where the ball just goes straight for the point, no matter what.
I would like to make it work as a normal pong, thanks in advance, for the potential help =)
Oh and of course, project link is there : http://scratch.mit.edu/projects/36341064/
If the ball is moving too fast it won't detect that it is hitting the player's racket.
Thanks captain obvious. I know why the thing is happening. I asked HOW can i solve it, instead of saying the thing i know already ._.
Scratch is probably just lagging so it doesn't detect the ball is touching the racket. By “when the ball starts picking up some speed” I assume that you have a script telling the ball to start moving faster as the game goes on. My suggesting is that you add this to the script that increases speed:set [MAX SPEED v] to [10]
then add this:forever
if <(Speed) > (MAX SPEED) > then
forever
set [Speed v] to [10]
end
end
end
Well, that's some kind of an idea, if i won't find any better ,i'll use that one. But still i would like to get that more speed every time pong racket gets hit. I simply don't have an idea how to make it different. Right now iam using a
move () stepsSo maybe there's an alternative what will solve that? Thanks in advance, once again

- Imaginary_Numbers
-
Scratcher
42 posts
Need help with Ping Pong game !
Ok I discovered your problem. You are using the move _ steps block. So basically, after the ball gets enough speed it is moving so many steps at a time that it is actually jumping over the racket. Here is one way you could fix that. There is a potential of being a bit slower but I have used something like it and the lag wasn't a problem.
First you need to define how much the ball moves in the variable “speed” (Yes, the value of speed CAN change and get bigger as the game goes on)
Now use this script assuming that the “move _ steps” block is in a forever, or repeat until loop:
so basically just put the entire “repeat speed” block (and the move block inside it) in place of the “move _ steps” block. I am 99.99% sure that this is your problem and this should probably work if your script is set up the way I think it is,
First you need to define how much the ball moves in the variable “speed” (Yes, the value of speed CAN change and get bigger as the game goes on)
set [Speed v] to [1]
Now use this script assuming that the “move _ steps” block is in a forever, or repeat until loop:
forever
repeat (speed)
move (1) steps
end
end
so basically just put the entire “repeat speed” block (and the move block inside it) in place of the “move _ steps” block. I am 99.99% sure that this is your problem and this should probably work if your script is set up the way I think it is,
- cauzality
-
Scratcher
100+ posts
Need help with Ping Pong game !
The game looks great, nice work!
You created this problem when you “solved” another one i bet. In the ball's scripts, I assume you put the if blocks that check for when you touch a paddle in its own forever loop because you can pause them with the wait blocks without pausing the forever loop with the move block in it. That was probably your fix for the ball getting stuck in the paddles.
That's the problem. The two loops may run at different speeds. You're moving more frequently than your are checking for paddle collisions. If they were in the same loop, you would do them 1 to 1 and could solve this problem. Then of course your fix for getting stuck (the wait blocks) will have to go because they will pause you ball's motion now.
So use just one forever loop or at least just put the move block in the other forever. You will want to delete the wait blocks there too. You will be back to the drawing board with the getting stuck part. But you could try only bouncing off player 1 if direction < 0 (moving to the left) and only bouncing of player 2 if direction > 0 (moving to the right). That way, he'll only turn right at the left paddle and only turn left at the right paddle.
You created this problem when you “solved” another one i bet. In the ball's scripts, I assume you put the if blocks that check for when you touch a paddle in its own forever loop because you can pause them with the wait blocks without pausing the forever loop with the move block in it. That was probably your fix for the ball getting stuck in the paddles.
That's the problem. The two loops may run at different speeds. You're moving more frequently than your are checking for paddle collisions. If they were in the same loop, you would do them 1 to 1 and could solve this problem. Then of course your fix for getting stuck (the wait blocks) will have to go because they will pause you ball's motion now.
So use just one forever loop or at least just put the move block in the other forever. You will want to delete the wait blocks there too. You will be back to the drawing board with the getting stuck part. But you could try only bouncing off player 1 if direction < 0 (moving to the left) and only bouncing of player 2 if direction > 0 (moving to the right). That way, he'll only turn right at the left paddle and only turn left at the right paddle.
Last edited by cauzality (Jan. 29, 2015 03:10:01)
- vmyhscratchsep
-
Scratcher
85 posts
Need help with Ping Pong game !
Hello there guys. Lately i created a PONG! game on scratch, and in my opinion it looks decent (by thoughts that iam new to scratch).Go look at the Hour of Code 2014 or follow the steps on the ? sign or look at my program Possiball
The thing is, that whenever the ball gets at some speed, it just skips the racket, and it passes by. I don't have any ideas on how to solve that problem.
Right now the game is about surviving to the, let's say DEAD SPEED where the ball just goes straight for the point, no matter what.
I would like to make it work as a normal pong, thanks in advance, for the potential help =)
Oh and of course, project link is there : http://scratch.mit.edu/projects/36341064/
- blondie_2020
-
New Scratcher
1 post
Need help with Ping Pong game !
How do I get the ball to wait befor it starts to move?????????
- Discussion Forums
- » Help with Scripts
-
» Need help with Ping Pong game !





