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

#1 2008-08-26 17:48:45

keroro645
Scratcher
Registered: 2008-06-07
Posts: 1000+

gravity?

How do you do gravity?

Last edited by keroro645 (2008-08-26 17:48:58)

Offline

 

#2 2008-08-26 18:23:32

deerel
Scratcher
Registered: 2008-08-23
Posts: 89

Re: gravity?

Try this:

create variable gravity, global (for all sprites)
set it to some NEGATIVE number

Then, in each sprite where you want to have gravity, put this script (variable fallv should be local, that is 'for this sprite only'):

<when green flag clicked>
<set{ fallv }to( 0
<forever>
<change{ fallv }by( gravity
<change y by( fallv
<if><( <y position> <<> -179 )>
(now, the sprite has fallen on the ground)
(if you want penalize the sprite for the impact, the energy of the impact is roughly (( <{ fallv }> <*> <{ fallv }> ))
You can do what you want, for example hide the sprite, or if you want to let the sprite stay on the ground, these two lines will help:
<set y to( -179
<set{ fallv }to( 0
<end>
<end>

After you have it for 1 sprite, simply drag it to other sprites, the variable fallv gets crated automatically.

This is only basic thing, of course you will probably customize it for your purpose.

Last edited by deerel (2008-08-26 19:07:39)

Offline

 

#3 2008-08-26 18:30:08

keroro645
Scratcher
Registered: 2008-06-07
Posts: 1000+

Re: gravity?

nevermind do you know how to do like a damage type thing?The more damage you have the farther you go when hit.

Offline

 

#4 2008-08-26 18:31:50

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: gravity?

keroro645 wrote:

nevermind do you know how to do like a damage type thing?The more damage you have the farther you go when hit.

You know how you set gravity to a certain number when you jump? Well, make a damage variable and change it by the damage/10 or something


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#5 2008-08-26 18:38:39

deerel
Scratcher
Registered: 2008-08-23
Posts: 89

Re: gravity?

Bluestribute wrote:

keroro645 wrote:

nevermind do you know how to do like a damage type thing?The more damage you have the farther you go when hit.

You know how you set gravity to a certain number when you jump? Well, make a damage variable and change it by the damage/10 or something

I'm sorry, I don't get it. Neither keroro neither Bluestribute :-) Could you explain slower, maybe I understand and answer... :-|

Offline

 

#6 2008-08-26 18:40:18

Juzzy
Scratcher
Registered: 2008-08-24
Posts: 100+

Re: gravity?

Gravity is sort of like velocity then. Except some scripts are a little different. But sorta the same  smile  .

Last edited by Juzzy (2008-08-26 18:40:38)


If you are reading this turn around, walk 3 steps, and do the chickendance
smile  big_smile  smile  big_smile  Which smiley is happier?

Offline

 

#7 2008-08-26 19:26:58

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: gravity?

For gravity try checking out the code in this project.
http://scratch.mit.edu/projects/archmage/58354


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#8 2008-10-12 17:01:02

ssbbmakering
Scratcher
Registered: 2008-09-20
Posts: 1

Re: gravity?

This Is My Way Of Gravity
<when green flag clicked><forever if><<  <not>  >><touching[Ground Color]<move(Any)steps><point towards(Down]

Offline

 

#9 2008-10-12 17:12:47

keroro645
Scratcher
Registered: 2008-06-07
Posts: 1000+

Re: gravity?

this old so i dont need any help.I already know this now.  smile

Offline

 

#10 2008-10-13 16:33:26

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: gravity?

ssbbmakering wrote:

This Is My Way Of Gravity
<when green flag clicked><forever if><<  <not>  >><touching[Ground Color]<move(Any)steps><point towards(Down]

That's not realistic. It just makes things go down if not touching the ground, there's no gradual velocity changes.

Offline

 

Board footer