Well that's a really broad question there... gravity can be very simple or very complex, depending on how hard you want to work on it. But to answer your question, the easiest way to add gravity to a sprite is to make a script like this:
When Green Flag Clicked Forever If [sprite y > (whatever you want the y position of the "floor" to be)] change y by (a negative number of your choice) End Forever
Offline
http://scratch.mit.edu/projects/Ratty1967UK/1207378
Try that project - it's nothing fancy, just a load of bouncing balls under the influence of gravity!
Offline
Harakou wrote:
Well that's a really broad question there... gravity can be very simple or very complex, depending on how hard you want to work on it. But to answer your question, the easiest way to add gravity to a sprite is to make a script like this:
Code:
When Green Flag Clicked Forever If [sprite y > (whatever you want the y position of the "floor" to be)] change y by (a negative number of your choice) End Forever
im asuming you put a move down 5 in there
Offline
icecube46 wrote:
Harakou wrote:
Well that's a really broad question there... gravity can be very simple or very complex, depending on how hard you want to work on it. But to answer your question, the easiest way to add gravity to a sprite is to make a script like this:
Code:
When Green Flag Clicked Forever If [sprite y > (whatever you want the y position of the "floor" to be)] change y by (a negative number of your choice) End Foreverim asuming you put a move down 5 in there
"a negative number of your choice" - Yes.
Offline
Harakou wrote:
icecube46 wrote:
Harakou wrote:
Well that's a really broad question there... gravity can be very simple or very complex, depending on how hard you want to work on it. But to answer your question, the easiest way to add gravity to a sprite is to make a script like this:
Code:
When Green Flag Clicked Forever If [sprite y > (whatever you want the y position of the "floor" to be)] change y by (a negative number of your choice) End Foreverim asuming you put a move down 5 in there
"a negative number of your choice" - Yes.
you seem like a goos one too ask.. can you have a player draw a sprite to use as his/her character?????
Offline
icecube46 wrote:
Harakou wrote:
icecube46 wrote:
im asuming you put a move down 5 in there"a negative number of your choice" - Yes.
you seem like a goos one too ask.. can you have a player draw a sprite to use as his/her character?????
Not in any efficient way... you can give them the option to choose from several preloaded ones, but I can't think of any good way to let them draw their own. Sorry.
Offline
Harakou wrote:
icecube46 wrote:
Harakou wrote:
"a negative number of your choice" - Yes.you seem like a goos one too ask.. can you have a player draw a sprite to use as his/her character?????
Not in any efficient way... you can give them the option to choose from several preloaded ones, but I can't think of any good way to let them draw their own. Sorry.
![]()
ok can you show me how to be able 2 choose???
Offline
icecube46 wrote:
Harakou wrote:
icecube46 wrote:
you seem like a goos one too ask.. can you have a player draw a sprite to use as his/her character?????Not in any efficient way... you can give them the option to choose from several preloaded ones, but I can't think of any good way to let them draw their own. Sorry.
![]()
ok can you show me how to be able 2 choose???
The easiest way is just to have a sprite for each costume (in some sort of character-selection screen). Have each sprite, when it's clicked, set a variable (call it whatever you want, "character" for example.) that corresponds to the costume number on the player sprite. Then on the player sprite, have it switch to the appropriate costume with this block: "Switch to costume (character)" For example, if the second costume was Mario, then clicking on the Mario character selection sprite should set "Character" to 2. That way, the player sprite will switch to costume #2, i.e. Mario.
I hope that makes sense.
Offline
icecube46 wrote:
ok so how u make it so when it touches a platform it stops but u can still move
That can be done multiple ways, but the easiest is just
Forever if <not <touching color (whatever)> > change y by (a negative number of your choice) End Forever
Offline
If you are doing a jagged floor this is a good script:
1st: Make a spirte called "ground", duplacate it and call that sprite "bottom ground", put it a few pixels away from "ground"
2nd :Add a variable "ignore gravity"
3rd: Add this script
when green flag clicked
forever
if ingnore gravity = 0
if touching ground
else
change y by -10
when green flag clicked
forever
if touching bottom ground
change y by 2
Offline
Here is a project on how to make gravity:
http://scratch.mit.edu/projects/HD123/1343219
It is realistic, and it works for an uneven floor.
Last edited by HD123 (2010-10-30 11:53:55)
Offline