This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-09-28 20:22:10

Transformed71506
New Scratcher
Registered: 2010-09-27
Posts: 8

Bouncing Help

Hello

I need some help please!  I am new to Scratch and having a heck of a time getting my sprite (basketball) to bounce off my 2nd sprite (wall).  I am using an angle variable and want the ball to bounce off the wall at the same angle it hit the wall (reflection).

I loaded my project under Transformed71506

Any help would be awesome!  Let me know if you need any further information.

Thanks!

Offline

 

#2 2010-09-28 20:29:07

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Bouncing Help

Is the wall vertical or horizontal?


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2010-09-28 20:32:13

Transformed71506
New Scratcher
Registered: 2010-09-27
Posts: 8

Re: Bouncing Help

This is what I have so far:

blocks
<when green flag clicked>
<clear>
<pen up>
<go to x sad  -200 )y sad  -50 )
<point in direction( 0 )
<turn cw( <{ angle }> )degrees>
<move( 150 )steps>
<if><color[ red ]is touching[ black ]
<turn cw( <{ angle }> )degrees><end>
<move( 150 )steps>
/blocks

Offline

 

#4 2010-09-28 20:37:32

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Bouncing Help

Okay, but is the wall vertical?


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#5 2010-09-28 20:38:47

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: Bouncing Help

Under examples, there is a project called pong that will probably help a lot!
big_smile -12three- big_smile

Offline

 

#6 2010-09-28 20:42:18

Transformed71506
New Scratcher
Registered: 2010-09-27
Posts: 8

Re: Bouncing Help

horizontal

Offline

 

#7 2010-09-28 21:01:33

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Bouncing Help

In that case, just use [Point in direction (180 - direction)]  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#8 2010-09-28 21:16:28

Transformed71506
New Scratcher
Registered: 2010-09-27
Posts: 8

Re: Bouncing Help

So you mean:

[Point in direction (180-angle)]

And place it where in the blocks?

I am sorry.  I am such a rookie!

Thanks!

Offline

 

#9 2010-09-28 21:25:02

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Bouncing Help

Ah. Sorry. Just put this script within the movement script.

Code:

If <touching wall>
    point in direction (180 - direction)
    repeat until <not <touching wall> >
        move (whatever) steps
    end
end

The forever if script is important, because it keeps the sprite from bouncing several times.

Last edited by Harakou (2010-09-28 21:25:16)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#10 2010-09-28 21:54:47

Transformed71506
New Scratcher
Registered: 2010-09-27
Posts: 8

Re: Bouncing Help

I am still so lost!

I tried your code and it still would not work.

I am ok until the 1st <turn cw( <{ angle }> )degrees>

I was working on getting the ball to move so that is why I added <move( 150 )steps>

I was playing with the glide block but it kept going over the wall.

I need for the ball to sense the wall, bounce off at the same angle it initially hit, and stop.

I keep adjusting blocks but nothing seems to work!

Any suggestions???

Offline

 

#11 2010-09-28 23:26:05

Transformed71506
New Scratcher
Registered: 2010-09-27
Posts: 8

Re: Bouncing Help

Got it!

Thanks for all your help Scratch Community!

Offline

 

Board footer