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

#1 2012-02-26 12:20:30

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

Slant/Hill Sensing

I am making a 1s1s (1 sprite, 1 script) game. I need it to sense when it is on a hill so that it can roll down. This is what I have right now:

change x by (6)
if <color [#0000E3] is touching color [#0AF225]>
change x by (-6)
else
change x by (-12)
if <color [#0000E3] is touching color [#0AF225]>
change x by (6)
end
end
= ground color
= bottom of sprite

I already have the gravity done. That's why I just leave it in mid-air if the sensing is true.

Please [help].
Thanks! - PullJ(0)sh

Last edited by PullJosh (2012-02-26 12:23:10)


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

 

#2 2012-02-26 16:05:05

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Slant/Hill Sensing

I'm afraid it isn't that easy....
I'm not even exactly sure how to do it.  hmm


6418,

Offline

 

#3 2012-02-26 19:26:15

hello12345678910
Scratcher
Registered: 2009-07-11
Posts: 100+

Re: Slant/Hill Sensing

Try:

Change x by 10 (or any suitable number)
if <not<<color [blue] is touching color [green]>>>
change [x velocity] by 5
end
change x by ( - (double your original number))
if <not<<color [blue] is touching color [green]>>>
change [x velocity] by -5
end
change x by (your original number)

Last edited by hello12345678910 (2012-02-26 19:28:20)


http://tinyurl.com/8yt32o9 http://tinyurl.com/6tgwp5r || Fish = F+I+S+H = 6+9+19+8 = 42<<The answer to Life, the Universe and Everything

Offline

 

#4 2012-02-26 23:09:43

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: Slant/Hill Sensing

Try looking at DarthPickley's project, here for some excellent slope detection and very accurate physics.


http://trinary.tk/images/signature_.php

Offline

 

#5 2012-02-27 07:12:55

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

Re: Slant/Hill Sensing

trinary wrote:

Try looking at DarthPickley's project, here for some excellent slope detection and very accurate physics.

That one is a bit advanced. I just want something simple. Thanks though.  smile


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