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

#1 2012-03-10 12:20:59

bleucheese
Scratcher
Registered: 2011-06-15
Posts: 18

Need help with slopes and sensing

I am making a game with the main character as a ball. I want it to be able to roll up slopes, not just stop when it hits one. Whenever I try to go up a slope though, the ball goes right through it. Does anybody know how to fix this?

bleucheese


bleucheese :]

Offline

 

#2 2012-03-10 12:26:16

CoolGamesCY
New Scratcher
Registered: 2012-03-03
Posts: 15

Re: Need help with slopes and sensing

Yes.

The most simple way of doing it is like this:

_________________________________
When the green flag is pressed

[Forever if Touching colour (colour of the ground)]
[Change y by 1]

___________________________________________________

Offline

 

#3 2012-03-10 12:41:32

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Need help with slopes and sensing

This is really hard to do.
I suggest you use erkstock's sensor.

Offline

 

#4 2012-03-10 12:53:41

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Need help with slopes and sensing

Use a script that does this: Forever, sense whether it is touch a slope. Repeat until not touch a slope: change y by 1. Then use gravity.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#5 2012-03-10 13:59:51

bleucheese
Scratcher
Registered: 2011-06-15
Posts: 18

Re: Need help with slopes and sensing

I tried the change y by 1 script that bobbybee and CoolGamesCY suggested, and it does not go through the slope anymore, but it just goes straight to the top of the slope now. Any Ideas?


bleucheese :]

Offline

 

#6 2012-03-10 14:04:14

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: Need help with slopes and sensing

bleucheese wrote:

I tried the change y by 1 script that bobbybee and CoolGamesCY suggested, and it does not go through the slope anymore, but it just goes straight to the top of the slope now. Any Ideas?

try adding a change x by 1 straight after. if that doesn't work you'll need a more complicated script


http://i.imgur.com/1QqnHxQ.png

Offline

 

#7 2012-03-10 17:20:29

bleucheese
Scratcher
Registered: 2011-06-15
Posts: 18

Re: Need help with slopes and sensing

This is the script i am using:

when gf clicked
forever
if<key [right arrow v] pressed?>
change [x velocity v] by (-0.3)
if<key [left arrow v] pressed?>
change [x velocity v] by (0.3)
if<touching [ground v]?>
set [y velocity v] to (2)
if <key [up arrow v] pressed?>
set [y velocity v] to (18)
if <[up slope] = [yes]>
change [x velocity v] by (0.3)
change y by [1]
if<[down slope] = [yes]>
change [x velocity v] by (0.3)
change y by [1]
set [x velocity v] to ((x velocity) * [0.97])
change [x scroll v] by (x velocity)
change [y velocity v] by [-1]
change y by (y velocity)
turn ccw (x velocity) degrees
I didnt mean to put all those ifs together.

Last edited by bleucheese (2012-03-10 17:21:29)


bleucheese :]

Offline

 

#8 2012-03-10 19:00:01

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Need help with slopes and sensing

Yeah, you need to do a check for gravity so it can go down the slope.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#9 2012-03-10 20:28:34

bleucheese
Scratcher
Registered: 2011-06-15
Posts: 18

Re: Need help with slopes and sensing

What do you mean a check for gravity?


bleucheese :]

Offline

 

Board footer