Assuming you're using the arrow keys for the controls:
when Green Flag clicked
forever
if <key [left arrow] pressed>
change x by -2
if <key [right arrow] pressed>
change x by 2
if <key [up arrow] pressed>
repeat 10
change y by 1
end repeat
if <key [down arrow] pressed>
switch to costume [crouch]I'm afraid for crouching you're going to have to modify your sprite to make it look like he's crouching in a separate costume.
Hope that helped!
Also, jumping isn't 100% bugless in this particular code, and it also assumes you're automatically drifting towards the ground
Offline
Gveradux wrote:
Thanks, but when he jumpd I want him to come down again in a short time
Well, in most platformers, since the ground isn't always completely straight, you're going to want your sprite to automatically always be moving down unless you're touching the ground. If it's all the same colour, try this:
When Green Flag clicked
forever
if <not <touching color [color of ground]>>
change x by -1
end
endYou'll also want to revise my above code and make it change y by 2 while rising.
Offline