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

#1 2012-05-31 12:19:11

YOUR_BEING_RUDE
New Scratcher
Registered: 2012-05-31
Posts: 1

hi guys new to scratch can someone teach me how to make my sprite jump

i want to be able to control the direction of the jump so say my sprite jumped up i want him to be able to change direction while in the air can anyone help thx!!!

Offline

 

#2 2012-05-31 12:44:27

infinite_minus_zero
Scratcher
Registered: 2010-02-18
Posts: 100+

Re: hi guys new to scratch can someone teach me how to make my sprite jump

Most users do
when spacebar pressed
change y by 5
wait 1 sec
change y by -5

but this is choppy.

if want want smoother motion and longer hang time,
youll want to add regular.increaing exponential intervals on the Y axis along.withh decreasing jntervals.at the same rate.
(check out my Flea project. Its got it on there)
PS sorry if I sound like a.salesman. xD)

Offline

 

#3 2012-05-31 12:51:22

DHMockingjay
New Scratcher
Registered: 2012-04-12
Posts: 8

Re: hi guys new to scratch can someone teach me how to make my sprite jump

Try the script

when gf clicked
forever if <key [space v] pressed>
   repeat (10)
      change y by ( (x)  *  (x) )
      change [x v] by [1]
   end
   repeat (10)
      change y by ( (x)  *  (x) )
      change [x v] by [-1]
   end
end
as a part of a "one sprite, one script" structure and a jump script

Offline

 

#4 2012-05-31 19:43:57

infinite_minus_zero
Scratcher
Registered: 2010-02-18
Posts: 100+

Re: hi guys new to scratch can someone teach me how to make my sprite jump

DHMockingjay wrote:

Try the script

when gf clicked
forever if <key [space v] pressed>
   repeat (10)
      change y by ( (x)  *  (x) )
      change [x v] by [1]
   end
   repeat (10)
      change y by ( (x)  *  (x) )
      change [x v] by [-1]
   end
end
as a part of a "one sprite, one script" structure and a jump script

Yes, that. What he said.

Offline

 

#5 2012-06-01 11:48:38

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: hi guys new to scratch can someone teach me how to make my sprite jump

I would try this:

1. Create a variable called "yvel".
2. Add this script to your sprite:

when gf clicked
set [yvel v] to [0]
forever
 if <touching [ground v]?> //Whatever your ground is. Edge works too.
  set [yvel v] to [0]
 else
  change y by (yvel)
  change [yvel v] by (-0.1)
 end
 if <<key [up arrow v] pressed?> and <touching [ground v]?>> //Your ground.
  repeat until <not <touching [ground v]?>> //Your ground.
   change y by (5)
  end
  set [yvel v] to [5]
 end
end

Last edited by SciTecCf (2012-06-01 11:51:12)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#6 2012-06-01 13:54:51

infinite_minus_zero
Scratcher
Registered: 2010-02-18
Posts: 100+

Re: hi guys new to scratch can someone teach me how to make my sprite jump

SciTecCf wrote:

I would try this:


if <touching [ground v]?> //Whatever your ground is. Edge works too.

[/scratchblocks]

Or you could set it to a certain colour, which you would outline the background/sprite in, wich I find works a little better. They both work though. Oh, and SciTecCfs' method works really nice too.

Offline

 

Board footer