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

#1 2010-07-16 08:27:01

helltank
Scratcher
Registered: 2010-05-21
Posts: 1000+

Gravity Script

Hi! Helltank here. This is how to generate artificial gravity, extremely useful and familiar to old timers, but strange and new for new scratchers:

Gravity Script:
When Flag Pressed
Forever
If Sprite touching <colour of floor>
Change Y/X(depends on project) by <amount>
Else Change Y/X by <amount>

Note: This script is NOT perfect. If the Sprite is big enough, you can notice it "vibrating" up and down. This is due to it falling into the floor but being pushed up again immediately.


Error:Signature could not load. Please wait for an indefinite amount of time, until you realize you're gullible and go off to look for another potentially interesting signature to stare at.

Offline

 

#2 2010-07-16 08:50:14

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

Re: Gravity Script

Great idea posting this! So many people have asked, now I can just tell them to go to this topic.

Bravo!  big_smile

Offline

 

#3 2010-07-16 12:47:22

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Gravity Script

Nice!
Coolstuff: And BTW, Make scape 2.


Hai.

Offline

 

#4 2010-07-16 23:45:05

helltank
Scratcher
Registered: 2010-05-21
Posts: 1000+

Re: Gravity Script

Bump! And coolstuff, do you think I should have put it in New Scratch Members instead?


Error:Signature could not load. Please wait for an indefinite amount of time, until you realize you're gullible and go off to look for another potentially interesting signature to stare at.

Offline

 

#5 2010-07-16 23:46:32

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

Re: Gravity Script

helltank wrote:

Bump! And coolstuff, do you think I should have put it in New Scratch Members instead?

Either place works fine  smile

Offline

 

#6 2010-07-17 14:55:57

Pokemonfan226
Scratcher
Registered: 2010-07-10
Posts: 13

Re: Gravity Script

<when green flag clicked>
<forever><if><key[ up arrow]pressed?>
<set{ Gravity }to( 10
<change y by( 10
<end>
<repeat until>
<touching[ edge
<change{  Gravity}by( -0.5
<change y by( <{  Gravity
<end><end>


http://sdb.drshnaps.com/objects/7/971/Sprite/DoraemonGBA.png

Offline

 

#7 2010-07-17 15:34:27

melikecheese
Scratcher
Registered: 2010-06-09
Posts: 500+

Re: Gravity Script

I just turned the script into a project but it won't let me upload  sad


http://i51.tinypic.com/987rb5.jpg
I am Dave! Yognaught.

Offline

 

#8 2010-07-17 18:23:27

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Gravity Script

According `to Scratch's front page uploads are temporarily disabled. wait a bit and try again.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#9 2010-07-17 18:55:29

Dazachi
Retired Community Moderator
Registered: 2009-09-12
Posts: 1000+

Re: Gravity Script

And once you get better at using this script, you will be able to modify it and fit to your needs.


Dazachi, Retired Community Moderator
May also know me as OJACheung.

Offline

 

#10 2010-07-17 21:34:32

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

Re: Gravity Script

Dazachi wrote:

And once you get better at using this script, you will be able to modify it and fit to your needs.

That's the joy of programming, isn't it? just about everything can be modified to suit your needs.

This is especially so with Scratch because of its unique interface... The Scratch team are geniuses!

[/marvelling]

Offline

 

#11 2010-07-17 22:24:18

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Gravity Script

The "vibrating" problem is really annoying, but I have a convoluted solution:

Code:

when flag clicked:
set [on ground?] to "false"
forever:
  if < on ground? = "true" >
  {
    if <not <touching [ground]?>>
    {
       set [on ground?] to "false"
    }
  }else{
    change [y velocity] by 1
    change y by (y velocity)
    if <touching [ground]?>
    {
      set [on ground?] to "true"
      repeat until <not <touching [ground]?>>
      {
        change y by -1
      }
    }
}

I feel like this should solve the problem, but it's been a while  smile


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#12 2010-07-18 01:14:18

helltank
Scratcher
Registered: 2010-05-21
Posts: 1000+

Re: Gravity Script

I did not understand you, fullmoon. Remember that I'm turning 11 this December...


Error:Signature could not load. Please wait for an indefinite amount of time, until you realize you're gullible and go off to look for another potentially interesting signature to stare at.

Offline

 

#13 2010-07-18 04:22:27

freejam
Scratcher
Registered: 2010-03-31
Posts: 3

Re: Gravity Script

try my double jump example

Offline

 

#14 2010-07-18 07:20:10

melikecheese
Scratcher
Registered: 2010-06-09
Posts: 500+

Re: Gravity Script


http://i51.tinypic.com/987rb5.jpg
I am Dave! Yognaught.

Offline

 

Board footer