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

#1 2007-12-05 18:04:31

Heliosa
Scratcher
Registered: 2007-07-24
Posts: 86

Making Gravity Witout Variables

Yes theres a way to make gravity without variables. First you make a sprite and place it at the bottom of the screen,preferablly a sprite that blends in with the backround. The you do this for the sprite that the gravitys going to affect.

                                 <when green flag clicked>
                                 <forever>
                                  <if>
                                  <<  <not><touching[ bottom sprite  >>
                                  <change y by( - 3

Then we do this for the same sprite.

                                                  <when[ Up ]key pressed>
                                                  <change y by( 10
             
That should make gravity for that sprite!


What are you looking at?

Offline

 

#2 2007-12-05 19:57:31

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Making Gravity Witout Variables

"Gravity" is not a constant velocity downward drift, but a constant downward acceleration, which gives increasing velocity.

Offline

 

#3 2007-12-05 20:00:01

Heliosa
Scratcher
Registered: 2007-07-24
Posts: 86

Re: Making Gravity Witout Variables

So it would be a force that moves things down at constantly the same speed (aka. Basic Gravity)


What are you looking at?

Offline

 

#4 2007-12-05 20:10:26

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Making Gravity Witout Variables

Moving things at a constant speed does not require variables, but getting them to accelerate (which is what gravity does unless you have a very high amount of friction) does require an extra variable to keep track of the current velocity.

If you are always falling from the same height, you may be able to compute the velocity from the y position, which would eliminate the need for a variable.

Offline

 

Board footer