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

#1 2012-11-25 00:25:59

IllusionOptics
Scratcher
Registered: 2011-10-15
Posts: 31

Platformer help?

How do you make gravity or make a character jump?


http://www.picturetrail.com/sfx/album/view/20154583

Offline

 

#2 2012-11-25 01:14:23

CopperHawk
Scratcher
Registered: 2011-09-23
Posts: 100+

Re: Platformer help?

IllusionOptics wrote:

How do you make gravity or make a character jump?

Here's a simple script:

when gf clicked
forever
if (up arrow pressed AND touching ground colour )
repeat (?)
change y by (speed)
end
repeat until ( touching ground colour)
change y by ( - speed )
end
else
if (not touching ground colour)
repeat until ( touching ground colour)
change y by ( - speed )

Last edited by CopperHawk (2012-11-25 01:23:26)


Copper Games is...  "ridiculously amazing!" -Nomolos    "Way too fun!"-Liamadams "awesome!" -Wes64       "Amazing!  big_smile " -JJROCKER

Offline

 

#3 2012-11-25 05:20:15

AngryCamel
Scratcher
Registered: 2012-04-12
Posts: 2

Re: Platformer help?

Check out my Gravity tutorial!
http://scratch.mit.edu/projects/AngryCamel/2932671

Offline

 

#4 2012-11-25 10:30:48

mathfreak231
Scratcher
Registered: 2012-10-24
Posts: 80

Re: Platformer help?

CopperHawk wrote:

IllusionOptics wrote:

How do you make gravity or make a character jump?

Here's a simple script:

when gf clicked
forever
if <<key [up v] pressed?> and <touching color (ground color)?>>
repeat (x)
change y by (speed)
end
repeat until <touching color (ground color)?>
change y by ((0) - (speed))
end
else
if <not <touching color (ground color)?>>
repeat until <touching color (ground color)?>
change y by ((0)-(speed))

Fixed.


~This sig is false~
I'm on teh wiki!

Offline

 

#5 2012-11-25 11:25:52

CopperHawk
Scratcher
Registered: 2011-09-23
Posts: 100+

Re: Platformer help?

mathfreak231 wrote:

CopperHawk wrote:

IllusionOptics wrote:

How do you make gravity or make a character jump?

Here's a simple script:

when gf clicked
forever
if <<key [up v] pressed?> and <touching color (ground color)?>>
repeat (x)
change y by (speed)
end
repeat until <touching color (ground color)?>
change y by ((0) - (speed))
end
else
if <not <touching color (ground color)?>>
repeat until <touching color (ground color)?>
change y by ((0)-(speed))

Fixed.

Thanks. XD


Copper Games is...  "ridiculously amazing!" -Nomolos    "Way too fun!"-Liamadams "awesome!" -Wes64       "Amazing!  big_smile " -JJROCKER

Offline

 

#6 2012-12-16 09:32:45

IllusionOptics
Scratcher
Registered: 2011-10-15
Posts: 31

Re: Platformer help?

CopperHawk wrote:

mathfreak231 wrote:

CopperHawk wrote:

Here's a simple script:

when gf clicked
forever
if <<key [up v] pressed?> and <touching color (ground color)?>>
repeat (x)
change y by (speed)
end
repeat until <touching color (ground color)?>
change y by ((0) - (speed))
end
else
if <not <touching color (ground color)?>>
repeat until <touching color (ground color)?>
change y by ((0)-(speed))

Fixed.

Thanks. XD

how do you make a character jump while going right/left and the jump continues to bring it in the direction while jumping?

-Illusion

Last edited by IllusionOptics (2012-12-16 09:33:09)


http://www.picturetrail.com/sfx/album/view/20154583

Offline

 

#7 2012-12-17 18:32:58

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Platformer help?

IllusionOptics wrote:

how do you make a character jump while going right/left and the jump continues to bring it in the direction while jumping?

-Illusion

X and Y positions are generally independent of each other, so there shouldn't be much interference between jumping and moving right and left.  Placing the right and left motion in a separate script seems appropriate for this kind of jumping script.

Alternately, to put right/left motion into the same script, you need to see why you are unable to just place some right/left code in.  The reason why you can't move right and left with coding in the above script is because the repeat block shuts out the rest of the logic of the script while it is repeating.   You can copy/paste your right/left section of the script into the repeat block and put a second one outside the repeat block.  That way it will work whether you are jumping or not.

Last edited by Kileymeister (2012-12-17 18:33:45)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#8 2013-01-03 20:36:49

IllusionOptics
Scratcher
Registered: 2011-10-15
Posts: 31

Re: Platformer help?

Kileymeister wrote:

IllusionOptics wrote:

how do you make a character jump while going right/left and the jump continues to bring it in the direction while jumping?

-Illusion

X and Y positions are generally independent of each other, so there shouldn't be much interference between jumping and moving right and left.  Placing the right and left motion in a separate script seems appropriate for this kind of jumping script.

Alternately, to put right/left motion into the same script, you need to see why you are unable to just place some right/left code in.  The reason why you can't move right and left with coding in the above script is because the repeat block shuts out the rest of the logic of the script while it is repeating.   You can copy/paste your right/left section of the script into the repeat block and put a second one outside the repeat block.  That way it will work whether you are jumping or not.

Question:  While jumping, I cannot go left/right while in the air.  I tried out the scripts above and I couldn't do that.  Anything wrong, maybe?


http://www.picturetrail.com/sfx/album/view/20154583

Offline

 

#9 2013-01-03 21:18:57

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Platformer help?

IllusionOptics wrote:

Kileymeister wrote:

IllusionOptics wrote:

how do you make a character jump while going right/left and the jump continues to bring it in the direction while jumping?

-Illusion

X and Y positions are generally independent of each other, so there shouldn't be much interference between jumping and moving right and left.  Placing the right and left motion in a separate script seems appropriate for this kind of jumping script.

Alternately, to put right/left motion into the same script, you need to see why you are unable to just place some right/left code in.  The reason why you can't move right and left with coding in the above script is because the repeat block shuts out the rest of the logic of the script while it is repeating.   You can copy/paste your right/left section of the script into the repeat block and put a second one outside the repeat block.  That way it will work whether you are jumping or not.

Question:  While jumping, I cannot go left/right while in the air.  I tried out the scripts above and I couldn't do that.  Anything wrong, maybe?

try placing the right/left script in its own script if you haven't done so already.
the only reason you might need to combine them is for saving scripts as in 1sprite 1script projects, which is usually not the main goal, but rather to make a working game

Offline

 

Board footer