Pages: 1
Topic closed
Just do this
when key up pressed
repeat 30
change y by 3
repeat 30
change y by -3
That should make your sprite jump properly.
Offline
Try this
first make a platform sprite
{make character land on platform}
when key up pressed
repeat 30
change y by 3
repeat 30
if not touching platform
change y by -3
This will make it so he will not fall if touching a platform. However the sprite cannot fall down because he doesn't have gravity codes in him.
If you want gravity codes go to get new sprite from file then go into things and then select gravity ball.
If you are new to scratch and not experienced in programming it might be too confusing for you.
some examples of games that use gravity movement are
http://scratch.mit.edu/projects/archmage/9397
http://scratch.mit.edu/projects/archmage/12293
or if you want really basic gravity try this:
{put this on player sprite for basic gravity}
when flag clicked
forever
if jump =0 and not touching platform
change y by -3
{however for this to work we must also add the jump variable to the jump code}
when key up pressed
set jump to 1
repeat 30
change y by 3
repeat 30
if not touching platform
change y by -3
{add the set jump after the repeat block NOT inside it}
set jump to 0
Try it out and if you want I can program a demo of what I just talked about in this post.
Last edited by archmage (2007-06-18 18:00:28)
Offline
To make a variable go to variable's tab and create variable. And make the variable name jump. When you are done post your project and ill fix the bugs.
Also I forgot to add the forever in the basic gravity code I added it now.
Last edited by archmage (2007-06-18 18:01:18)
Offline
I made this http://scratch.mit.edu/projects/archmage/14600
It is a demonstration of what I was talking about feel download to download the project and look at the code that makes it tick.
Offline
try using a variable so a smooth jump is allowed.
set 'jump' to 10
repeat 21
[change y by jump,
change jump by -1
wait 0.01 seconds]
Offline
Topic closed
Pages: 1