Discuss Scratch

RichardStarbright
Scratcher
38 posts

Bouncing?

How do I make things bounce (like the ball in pong) without using “easy way out” blocks like
turn cw (pick random (some number) to (some number)) degrees
or
if on edge, bounce

Any help?

-PRO-
Scratcher
500+ posts

Bouncing?

That is the way to do it.

Diamond_Projects
Scratcher
100+ posts

Bouncing?

if <touching [thing v] ?> then

turn cw (90) degrees
move (10) steps
if <touching [thing v] ?> then

turn cw (180) degrees
repeat until <not <touching [thing v] ?>>

move (10) steps
end


end

end
(Credit to @DevanWolf)

Last edited by Diamond_Projects (Sept. 21, 2014 01:25:56)

RichardStarbright
Scratcher
38 posts

Bouncing?

Diamond_Projects wrote:

if <touching [thing v] ?> then

turn cw (90) degrees
move (10) steps
if <touching [thing v] ?> then

turn cw (180) degrees
repeat until <not <touching [thing v] ?>>

move (10) steps
end


end

end
(Credit to @DevanWolf)

The thing is, I appreciate the work, but you guys are kinda killing the point.

My point is: Is there any easy way to calculate an angle, and then from there, “bounce” (AKA adjust the angle and where its supposed to go)?

-PRO-
Scratcher
500+ posts

Bouncing?

Maybe a variable

wkelly42
Scratcher
100+ posts

Bouncing?

A simple way is to do it like I did in this script -> http://scratch.mit.edu/projects/25898438/

BUT there are problems with that. The angles are always the same - there needs to be a way to change the ball's direction slightly by moving the paddle. I'm currently working on that.

There was another thread on here talking about that that had a GREAT answer that I haven't had time to try to implement –> http://scratch.mit.edu/discuss/topic/50111/

My Retro Arcade:
COMPLETED: Frogger, Missile Command, Computer Space.
IN DEVELOPMENT: Barnstorming, Time Pilot, Defender, River Raid, Karateka

Powered by DjangoBB