Pages: 1
Topic closed
Hmm... we want to make this as realistic as possible right? Here is what I did for one of my games:
1. Create a variable called Gravity and another called Up Arrow Pressed?
2. You also need some sort of background or color that acts as the ground for the character. I will use the # symbol to signify this
3. Use these scripts:
When Green Flag Clicked
forever
if <key up arrow pressed>
change y by -2
if touching #
if <not <Up Arrow Pressed *= 1>
set gravity to 7
set Up Arrow Pressed* to 1
change y by gravity
change y by 2
change y by gravity
if <not <touching #>
change Gravity by -0.3
*(the variable)
I could go into MUCH MORE complicated movement scripts, but I think this answers your question. Scratch On!
Offline
shadow_7283 wrote:
Hmm... we want to make this as realistic as possible right? Here is what I did for one of my games:
1. Create a variable called Gravity and another called Up Arrow Pressed?
2. You also need some sort of background or color that acts as the ground for the character. I will use the # symbol to signify this
3. Use these scripts:
When Green Flag Clicked
forever
if <key up arrow pressed>
change y by -2
if touching #
if <not <Up Arrow Pressed *= 1>
set gravity to 7
set Up Arrow Pressed* to 1
change y by gravity
change y by 2
change y by gravity
if <not <touching #>
change Gravity by -0.3
*(the variable)
I could go into MUCH MORE complicated movement scripts, but I think this answers your question.Scratch On!
Leading onto the more complicated scripts would be like the ones found in my Perfect Platformer Base:
http://scratch.mit.edu/projects/RHY3756547/845502
It has some helpful comments, slope detection etc.
Offline
I tried doing the script shadow_7283 did, but it only made me go down. No, I didn't go back up. May somebody make a different script?
Offline
acester wrote:
I tried doing the script shadow_7283 did, but it only made me go down. No, I didn't go back up. May somebody make a different script?
Hm...
I looks like it should work. I'll make mine:
Again, # is the ground.
|when green flag clicked| [forever] change y by (-1) if <touching #> set Gravity to (0) if <key [up arrow] pressed?> set Gravity to 10 [end if] [else] change Gravity by (-1) [end if] change y by ((Gravity + 1)) [end forever]
Tell me if this works.
Last edited by MathWizz (2010-02-24 22:05:53)
Offline
acester wrote:
I tried doing the script shadow_7283 did, but it only made me go down. No, I didn't go back up. May somebody make a different script?
Could you post your project online? That's the best way for us to help.
Offline
I hope that this will work for you
P.S. I added scripts for the left and right arrow keys.
--------------------------------------------------------------------------
Background that I used:
Scripts that I used:
Offline
ThePCKid wrote:
I hope that this will work for you
P.S. I added scripts for the left and right arrow keys.
It's a nice example, but it doesn't have very realistic jumping like Mario does.
Offline
I had a really long if statement... I didn't know how to make the ground though... but here's what I have:
[blocks]
<if><key[ space ]pressed?>
<set{ hieght }to( 0
<repeat( 18<change{ hieght }by( 1
<change{ y }by( hieght
<if><key[ left arrow ]pressed?>
<change x by( -10
<if><key[ right aroow ]pressed?>
<change x by( 10
[/blocks]
So what I was doing was to go right basicly... but you could go either direction now. just press space with this which changes the variable of hieght and then press left or right arrow keys to move either way. tell me if it doesn't work.
Offline
It wouldn't work because it wouldn't go back down... and the gravity is opposite.
I don't mean to sound obnoxious but... just stick with my method.
Last edited by shadow_7283 (2010-03-01 20:17:54)
Offline
howlcall wrote:
[blocks]
<if><key[ space ]pressed?>
<set{ hieght }to( 0
<repeat( 18<change{ hieght }by( 1
<change{ y }by( hieght
<if><key[ left arrow ]pressed?>
<change x by( -10
<if><key[ right aroow ]pressed?>
<change x by( 10
[/blocks]
---------------------------------------------------------------------------
It worked for my project.
Think about it. What you are saying is repeat 18 times change [height] by 1, change y by height. So at the end of the script the character will move eighteen spaces up (with the y movement increasing EACH REPEAT). What about going back down?
Offline
Easy,when green flag clicked forever if key up arrow key pressed and touching color black reapeat 10 change y by 10.
Offline
I use this script, is not exactly floating back, but you can change the gravity to vary the speed that the person comes back down.
Offline
haniyamout1 wrote:
<set{gems }to(0
<say[ Hi gorge ]for( 3 )secs>
<say[ do you want som gems? ]for( 2 )secs>
<broadcast[next person
<when I receive[next person
<say[ yes please ]for( 1 )secs>
<change{gems }by(1
please dont spam.
Offline
Topic closed
Pages: 1