# Super Gravity

**URL:** https://forum.kirupa.com/t/super-gravity/56470
**Category:** flash
**Created:** [July 4, 2004, 7:21pm UTC](https://forum.kirupa.com/t/super-gravity/56470 "2004-07-04T19:21:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![yhack](https://avatars.discourse-cdn.com/v4/letter/y/3da27b/32.png) [@yhack](https://forum.kirupa.com/u/yhack)
#### Post date: [July 4, 2004, 7:21pm UTC](https://forum.kirupa.com/t/super-gravity/56470/1 "2004-07-04T19:21:39Z")

</div>

Hi, ive got bored of my other games 🙂 and i started a new one for the contest  
Im hoping for it to be simple

Your a little blob that runs through the world and cant stop running

there will be little holes with spikes or just a hole

what code do i put to make gravity pull it down but when its on the ground  
(MC “ground”) it stops you

thx in advance,  
yhack

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 4, 2004, 10:49pm UTC](https://forum.kirupa.com/t/super-gravity/56470/2 "2004-07-04T22:49:55Z")

</div>

Make a variable called “Gravity”.  
When your blob makes collision with the hole in the ground start the Gravity by making it “true”. Here’s a little example:

// ------------------------------------------------------------\>  
// setup a gravity  
onEnterFrame=function(){  
if(Gravity){  
//if true, make the blob fall  
blob.\_y++  
}  
// check if the blob hits one of the holes  
if(blob.hittest(hole,true)){  
Gravity=true;  
}else{  
Gravity=false;  
}  
}  
// ------------------------------------------------------------\>

This is just one simple ex. If you want to make it right, there are just serval thinks more that you must do,… try to find more information about platform games.

Good luck!

Martijn Himpers

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 5, 2004, 3:39pm UTC](https://forum.kirupa.com/t/super-gravity/56470/3 "2004-07-05T15:39:21Z")

</div>

thx, how do i make a variable… is it the thing in the text box when its dynamic and at the bottom?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 5, 2004, 4:01pm UTC](https://forum.kirupa.com/t/super-gravity/56470/4 "2004-07-05T16:01:56Z")

</div>

[http://www.kirupa.com/developer/actionscript/tricks/scope.htm](http://www.kirupa.com/developer/actionscript/tricks/scope.htm)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 5, 2004, 10:57pm UTC](https://forum.kirupa.com/t/super-gravity/56470/5 "2004-07-05T22:57:56Z")

</div>

:p: Making a variable is as simple as typing:

Gravity=true; …or… Gravity=false;

The value of Gravity is variable…true or false.  
Other variables are for example:

myName=“yhack”; …or… myNumber=123;

The value of myName and myNumber, its variable,…:p:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 5, 2004, 11:04pm UTC](https://forum.kirupa.com/t/super-gravity/56470/6 "2004-07-05T23:04:42Z")

</div>

how bout:

OnClipEvent(enterFrame) {  
gravity = 9.8;  
\_root.char.\_y += gravity;  
}  
OnClipEvent(enterFrame) {  
if (\_root.char.hitTest(ground)) {  
\_root.char.\_y -= 9.8;  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 6, 2004, 8:25am UTC](https://forum.kirupa.com/t/super-gravity/56470/7 "2004-07-06T08:25:41Z")

</div>

OnClipEvent is flash 5,… i see you have typed twice the clipEvent enterframe.  
The character doesnt fall when its standing on the ground, only when its hit a hole.

OnClipEvent(load) {  
gravity = 9.8;  
}

OnClipEvent(enterFrame) {  
if (\_root.blob.hitTest(hole)) {  
\_root.blob.\_y -= gravity;  
}  
}
