Discuss Scratch

Gnodab
New Scratcher
2 posts

Making the ball go faster in pong

Hi I just started working with Scratch and Im having tons of fun finding the solution to the problems at hand, but I can't seem to find a way to make the speed of the ball exponentially increase when it hits the paddle.
U can check on my profile what I have so far. Thanks in advance!
Lifeoftheparty29
Scratcher
17 posts

Making the ball go faster in pong

Change the number of steps the ball moves to a variable. Have that variable increase when the ball hits the paddle.
Ayarkay
Scratcher
73 posts

Making the ball go faster in pong

Like Lifeoftheparty29 said, you'd want the number of steps that the ball moves by to be a variable, let's call it Speed. Once you want the the ball to move faster, you multiply the Speed variable by a constant number. For example, whenever you want the speed to increase, you'd run:
setSpeedtoSpeed*1.5
Increasing the 1.5 value will cause the speed to increase faster, while a lower value closer to 1 will cause the speed to increase more slowly. Values lower than 1 will cause the speed to exponentially decrease.

If you wanted a linear increase in speed instead of an exponential one, you'd simply do:
setSpeedtoSpeed+10
The value that you add on to Speed would determine how much faster the ball would go every time you increased its speed.

Then, all you need is a way to periodically launch the above code. You could have a counter variable that increases by 1 every time a paddle is hit. Then, every time the counter reaches a certain number, it increases the speed, and then resets the counter.

ifCounter=5thensetSpeedtoSpeed*1.5setCounterto0

Last edited by Ayarkay (July 21, 2017 20:39:20)

Gnodab
New Scratcher
2 posts

Making the ball go faster in pong

I did something similar with variables and functions, but obviously not correct. Anyways good to know that I was looking in the right direction at least. Thanks!
glarfnemshwap
Scratcher
1 post

Making the ball go faster in pong

nbkuftc
deck26
Scratcher
1000+ posts

Making the ball go faster in pong

glarfnemshwap wrote:

nbkuftc
Please don't spam or necropost.
Altaccount1236
Scratcher
1 post

Making the ball go faster in pong

Any recommendations for 3.0?
The_Imaginarium
Scratcher
1000+ posts

Making the ball go faster in pong

Please don't spam or necropost.
samq64
Scratcher
1000+ posts

Making the ball go faster in pong

(Didn't relise the OP was 4 years old and the topic was necroposted.)

Last edited by samq64 (April 27, 2021 13:06:26)

Powered by DjangoBB