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

#1 2012-08-08 08:10:58

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Wall Jumping and acceleration along the x axis

I need a good wall jumping script and acceleration along the x axis script. I have tried to different wall jumping scripts and both do not work.  I have a good platform script.

Offline

 

#2 2012-08-08 08:21:57

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Wall Jumping and acceleration along the x axis

You can use this script for x movement:

when gf clicked
set [xvel v] to [0]
forever if <not <<key [right arrow v] pressed?> and <key [left arrow v] pressed?>>>
 if <key [left arrow v] pressed?>
  change [xvel v] by (-0.8) //Movement gain speed, must be negative
 end
 if <key [right arrow v] pressed?>
  change [xvel v] by (0.8) //Same as above, but not negative
 end
 change x by (xvel)
 set [xvel v] to ((xvel) - ((xvel) * (0.08))) //Friction, increase for faster stop
end


http://i50.tinypic.com/312u714.jpg

Offline

 

#3 2012-08-08 08:58:46

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Wall Jumping and acceleration along the x axis

Wall jumping assuming you have a sensor costume would be

forever
if <color [#00FF00] is touching [#FFFFFF]?>
if <<key [up arrow v] pressed?> and <key [left arrow v] pressed?>>
set [xvel v] to (4)
set [yvel v] to (7)
//this is for the right hand side, you'd use the right sensor for the left jump
//and negative numbers.
//green would be the top left sensor, and white would be your 
//wall colour
//

Last edited by zammer990 (2012-08-08 09:02:22)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#4 2012-08-08 11:30:54

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Re: Wall Jumping and acceleration along the x axis

Can you explain this script?

Offline

 

#5 2012-08-08 11:34:35

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Wall Jumping and acceleration along the x axis

BirdByte wrote:

You can use this script for x movement:

when gf clicked
set [xvel v] to [0]
forever if <not <<key [right arrow v] pressed?> and <key [left arrow v] pressed?>>>
 if <key [left arrow v] pressed?>
  change [xvel v] by (-0.8) //Movement gain speed, must be negative
 end
 if <key [right arrow v] pressed?>
  change [xvel v] by (0.8) //Same as above, but not negative
 end
 change x by (xvel)
 set [xvel v] to ((xvel) - ((xvel) * (0.08))) //Friction, increase for faster stop
end

I just noticed quite a few bugs here. Try this instead:

when gf clicked
set [xvel v] to [0]
forever
 if <not <<key [right arrow v] pressed?> and <key [left arrow v] pressed?>>>
  if <key [left arrow v] pressed?>
   change [xvel v] by (-0.8) //Movement gain speed, must be negative
  end
  if <key [right arrow v] pressed?>
   change [xvel v] by (0.8) //Same as above, but not negative
  end
 end
 change x by (xvel)
 set [xvel v] to ((xvel) - ((xvel) * (0.08))) //Friction, increase for faster stop
end


http://i50.tinypic.com/312u714.jpg

Offline

 

#6 2012-08-08 11:47:06

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Re: Wall Jumping and acceleration along the x axis

I meant the wall jumping script. Are the red blocks ones that were hacked? Could you explain the wall jumping script.

Offline

 

#7 2012-08-08 11:49:31

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Wall Jumping and acceleration along the x axis

zammer990 wrote:

Wall jumping assuming you have a sensor costume would be

forever
if <color [#00FF00] is touching [#FFFFFF]?>//green would be the top left sensor, and white would be your wall color
if <<key [up arrow v] pressed?> and <key [left arrow v] pressed?>>//this is for the right hand side, you'd use the right sensor for the left jump and negative numbers.
set [xvel v] to (4)
set [yvel v] to (7)

Fixed.  smile


http://i50.tinypic.com/312u714.jpg

Offline

 

#8 2012-08-08 12:23:23

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Wall Jumping and acceleration along the x axis

BirdByte wrote:

zammer990 wrote:

Wall jumping assuming you have a sensor costume would be

forever
if <color [#00FF00] is touching [#FFFFFF]?>//green would be the top left sensor, and white would be your wall color
if <<key [up arrow v] pressed?> and <key [left arrow v] pressed?>>//this is for the right hand side, you'd use the right sensor for the left jump and negative numbers.
set [xvel v] to (4)
set [yvel v] to (7)

Fixed.  smile

Yea, i just do comments at the end so you can read them


And the red blocks are just blocks that dont exist, the forum makes them when you write a commment, not hacked blocks


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#9 2012-08-13 07:46:41

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Re: Wall Jumping and acceleration along the x axis

Does not work.

Offline

 

#10 2012-08-13 08:48:45

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Wall Jumping and acceleration along the x axis

This was my answer to a question for "a wall jumping script without sensors":

when gf clicked
forever
if<key [right arrow v] pressed?> // increase velocity if right key pressed
change [x-vel v] by (0.2)
end
if<key [left arrow v] pressed?> // decrease velocity if left key pressed
change [x-vel v] by (-0.2)
end
change x by (x-vel) // move sprite by x-velocity
if<touching [wall/floor v]?> // if sprite collides with wall
set [x-vel v] to ((-0.5)*(x-vel)) // bounce off
change x by (x-vel)
if<touching [wall/floor v]?>
change x by (x-vel)
end // after bouncing off the wall...
if<<key [up arrow v] pressed?> and <(y-vel) < (0)>> // see if you should wall bounce
set [y-vel v] to (3)
if<(x-vel) > (0)>
set [x-vel v] to (2)
else
set [x-vel v] to (-2)
end
end
end
change [y-vel v] by (-0.2) // gravity
change y by (y-vel) // move sprite along the y-axis
if<touching [wall/floor v]?> // if touching wall/floor
set [x-vel v] to ((0.94)*(x-vel)) // friction
set [y-vel v] to ((-0.5)*(y-vel)) // bounce
change y by (y-vel)
if<touching [wall/floor v]?>
change y by (y-vel)
end
if<<key [up arrow v] pressed?> and <(y-vel) > (0)>> // jump
set [y-vel v] to (4)
end
else
set [x-vel v] to ((x-vel)*(0.98)) // friction in the air (not on the ground)
end
Edit: added comments

Last edited by MoreGamesNow (2012-08-13 08:51:27)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#11 2012-08-13 16:18:49

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Re: Wall Jumping and acceleration along the x axis

Is it okay to remove if key right arrow/left arrow move x. I have a solid objects script and the x movement is crucial for it to work. Will it work without this?

Offline

 

#12 2012-08-13 17:19:26

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Wall Jumping and acceleration along the x axis

concentrating wrote:

Is it okay to remove if key right arrow/left arrow move x. I have a solid objects script and the x movement is crucial for it to work. Will it work without this?

If you remove the "if key [right arrow/left arrow]" blocks, how will you receive input?


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#13 2012-08-14 18:22:38

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Re: Wall Jumping and acceleration along the x axis

How will it effect the wall jumping.

Offline

 

#14 2012-08-14 19:44:05

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Wall Jumping and acceleration along the x axis

Wall jumping currently only work if your y-velocity is  less than zero when you hit the wall.  You can remove the conditional if you want.  I'm not sure how it will be affected, because I'm still not sure what you mean by removing the left and right arrow keys.  I'm assuming you're taking some other kind of input (different keys?  are you running into the object with another object?  what's your plan?)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#15 2012-08-17 10:36:21

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Re: Wall Jumping and acceleration along the x axis

With the platform script I have Y must be over zero to jump. What should I do?

Offline

 

#16 2012-08-17 11:17:01

concentrating
New Scratcher
Registered: 2012-06-28
Posts: 19

Re: Wall Jumping and acceleration along the x axis

I edited it and realized this script will not work with the floor and walls the same colors. And I fall through the floors even while moving. I need a different script.

Offline

 

#17 2012-08-30 09:58:01

starwiz
Scratcher
Registered: 2012-03-24
Posts: 57

Re: Wall Jumping and acceleration along the x axis

MoreGamesNow wrote:

This was my answer to a question for "a wall jumping script without sensors":

when gf clicked
forever
if<key [right arrow v] pressed?> // increase velocity if right key pressed
change [x-vel v] by (0.2)
end
if<key [left arrow v] pressed?> // decrease velocity if left key pressed
change [x-vel v] by (-0.2)
end
change x by (x-vel) // move sprite by x-velocity
if<touching [wall/floor v]?> // if sprite collides with wall
set [x-vel v] to ((-0.5)*(x-vel)) // bounce off
change x by (x-vel)
if<touching [wall/floor v]?>
change x by (x-vel)
end // after bouncing off the wall...
if<<key [up arrow v] pressed?> and <(y-vel) < (0)>> // see if you should wall bounce
set [y-vel v] to (3)
if<(x-vel) > (0)>
set [x-vel v] to (2)
else
set [x-vel v] to (-2)
end
end
end
change [y-vel v] by (-0.2) // gravity
change y by (y-vel) // move sprite along the y-axis
if<touching [wall/floor v]?> // if touching wall/floor
set [x-vel v] to ((0.94)*(x-vel)) // friction
set [y-vel v] to ((-0.5)*(y-vel)) // bounce
change y by (y-vel)
if<touching [wall/floor v]?>
change y by (y-vel)
end
if<<key [up arrow v] pressed?> and <(y-vel) > (0)>> // jump
set [y-vel v] to (4)
end
else
set [x-vel v] to ((x-vel)*(0.98)) // friction in the air (not on the ground)
end
Edit: added comments

It works Great even with the floor and the walls the same color! Thanks!


I am http://blocks.scratchr.org/API.php?user=starwiz&amp;action=onlineStatus and currently a member of the collab(s): Superio RPG My test account is http://blocks.scratchr.org/API.php?user=nova6&amp;action=onlineStatus
https://lh4.googleusercontent.com/-c33PEhGpnTU/UHnY9s7gsHI/AAAAAAAAABg/JIR0f7Tlcmc/h102/brav.png

Offline

 

Board footer