Discuss Scratch

ScarVf
Scratcher
30 posts

I'm am really having A LOT of trouble with my pong project! :( :/

Okay okay I know most of the problems are fixed like the ball projectile glitch (before it was shared it had trouble bouncing) Now I can't fix the ball geting stuck in the paddles (usually the red paddle) the bug is out of my coding leage so I hope it is someone elses leage.

Dyno_Bot
Scratcher
500+ posts

I'm am really having A LOT of trouble with my pong project! :( :/

Link? I've dealt with ping pong / pong
legendary34678
Scratcher
1000+ posts

I'm am really having A LOT of trouble with my pong project! :( :/

Hello! You can simply change the ball's movement from using the move block to this:

First, create two variables called speed-x and speed-y.. These will be how much the ball moves in the x and y directions.

when green flag clicked
point in direction (pick random (1) to (359)) //Point in a direction
set [speed-x v] to ([sin v] of (direction))
set [speed-y v] to ([cos v] of (direction))
forever
change x by (speed-x)
if <<touching [red paddle v]?> or <touching [blue paddle v]?>> then
set [speed-x v] to ((-1) * (speed-x))
change x by (speed-x)
end
change y by (speed-y)
if <<touching [red paddle v]?> or <touching [blue paddle v]?>> then
set [speed-y v] to ((-1) * (speed-y))
change y by (speed-y)
end
end

This block of code should handle all bouncing required. Simply put this in your ball sprite to replace how you're currently making it move.
ScarVf
Scratcher
30 posts

I'm am really having A LOT of trouble with my pong project! :( :/

Thank you! I'll see if i can implement it in to the game!

Powered by DjangoBB