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

#1 2012-03-07 23:54:28

JDProducers
Scratcher
Registered: 2011-12-17
Posts: 40

I Need Help!!!! Sprite Goes Through Ground If Up Arrow Held Down!!! :O

I need help with my project. I used vel. for Y and X, then whenever up arrow key is held it goes through the ground.
I used a script that uses sensor sprites that go all around the sprite. The bottom sensor set Xvel. to 0 every time it touches the level. and when up arrow key not pressed. That means that if the up arrow key is not pressed it will set Xvel. to 0. But if it is pressed it won't set Xvel. to 0. I need help with this script!!!
  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes


[img]C:\Documents and Settings\Administrator\My Documents\JDProducers Logo.BMP[/img]

Offline

 

#2 2012-03-08 05:43:04

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: I Need Help!!!! Sprite Goes Through Ground If Up Arrow Held Down!!! :O

Move the xvel out of the IF loop if it's in a

if <not <key [up arrow v] pressed?>>
... stuff ...
end
loop.

Last edited by rdococ (2012-03-08 05:43:19)

Offline

 

#3 2012-03-08 07:41:18

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: I Need Help!!!! Sprite Goes Through Ground If Up Arrow Held Down!!! :O

Also, make sure that you're working with YVEL instead of XVEL...Y is the vertical axis.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2012-03-08 07:52:36

PullJosh
Scratcher
Registered: 2011-08-01
Posts: 500+

Re: I Need Help!!!! Sprite Goes Through Ground If Up Arrow Held Down!!! :O

JDProducers wrote:

I need help with my project. I used vel. for Y and X, then whenever up arrow key is held it goes through the ground.
I used a script that uses sensor sprites that go all around the sprite. The bottom sensor set Xvel. to 0 every time it touches the level. and when up arrow key not pressed. That means that if the up arrow key is not pressed it will set Xvel. to 0. But if it is pressed it won't set Xvel. to 0. I need help with this script!!!
  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes  yikes

Does it float in mid-air? If it does, you need to make it so that if the bottom one is touching the ground, set y vel to 0. If it isn't, change y vel by -0.1. For the top sensor, if it's touching it should set y vel to y vel * -1 / 2. Let me show you:

when gf clicked
forever
if <the top is touching>
set [Yvel v] to (((Yvel) * (-1)) / (2))
end
if <the bottom is touching>
set [Yvel v] to (0.7)
else
change [Yvel v] by (-0.1)
end
if <key [right arrow v] pressed?>
change [Xvel v] by (2)
end
if <key [left arrow v] pressed?>
change [Xvel v] by (-2)
end
if <(Xvel) > (7)>
set Xvel to (7)
end
if <(Xvel) < (-7)>
set Xvel to (-7)
end
change x by (Xvel)
change y by (Yvel)
if <(letter (1) of (Xvel)) = [-]>
change [Xvel v] by (0.5)
else
change [Xvel v] by (-0.5)
end

I don't know for sure that it will work, but I think it will.

Last edited by PullJosh (2012-03-08 16:16:45)


http://www.blocks.scratchr.org/API.php?action=text&amp;string=I'm_on_vacation!&amp;xpos=155&amp;ypos=90&amp;font_size=30&amp;bgimage=http://imageshack.us/a/img339/7215/sspeechsigapiforwords.png

Offline

 

Board footer