This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-06-19 07:33:43

Gveradux
Scratcher
Registered: 2010-06-18
Posts: 100+

Need help making sprite move

Im trying to make a platform game and I can't get my sprite to move. I want him to jump, move right and left and crouch. Can you help me plz?

Offline

 

#2 2010-06-19 07:38:46

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Need help making sprite move

Assuming you're using the arrow keys for the controls:

Code:

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  smile

Offline

 

#3 2010-06-19 07:54:11

Gveradux
Scratcher
Registered: 2010-06-18
Posts: 100+

Re: Need help making sprite move

Thanks, but when he jumpd I want him to come down again in a short time

Offline

 

#4 2010-06-19 07:57:12

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Need help making sprite move

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:

Code:

When Green Flag clicked
forever
  if <not <touching color [color of ground]>>
    change x by -1
  end
end

You'll also want to revise my above code and make it change y by 2 while rising.

Offline

 

Board footer