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

#1 2007-06-24 03:26:47

SKRATCHER
Scratcher
Registered: 2007-06-24
Posts: 2

Reflection Formula

Sticky? Please?

Create the following sprites:

Left wall
Right wall
Top wall
Bottom wall

Make these long lines that border your project
--------------------------------------------------------------------
Ball

Make this a circular ball about the size of a pea in real life.
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
Make these variables:

A
B

***********************************
Add this code in the ball:
**************************
To reflect:
***************************
When flag clicked
forever {
if touching left wall or right wall
set A to direction
set B to 90 - A
Point in direction ((B * 2) + A)+180)
}
***************************
When flag clicked
forever {
if touching Top wall or Bottom wall
set A to (direction - 270)
set B to 90 - A
Point in direction ((90 + A)+(B * 2))
}

********************************
To make the ball move:
********************************

When flag clicked
forever {
move 2 steps
}

Hope it helps!

SKRATCHER
http://s35.photobucket.com/albums/d189/dimebar_probably/Smileys/th_chainsaw.gif

"this'll SKRATCH ya! "

Last edited by SKRATCHER (2007-06-25 01:27:54)

Offline

 

#2 2007-06-28 01:34:44

SKRATCHER
Scratcher
Registered: 2007-06-24
Posts: 2

Re: Reflection Formula

anyone?

Offline

 

#3 2007-06-28 15:40:41

relyt12101
Scratcher
Registered: 2007-05-19
Posts: 500+

Re: Reflection Formula

A and B can be variables. Walls can be sprites.

Could you explain this to me? I don't get why you said this -->.


http://img392.imageshack.us/img392/2860/pspbanneregg089deiy0.png

Offline

 

Board footer