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

#1 2013-04-26 17:14:27

FreaK001
New Scratcher
Registered: 2013-04-13
Posts: 15

What numbers should I use with the Pick random [] to []?? Help please.

What numbers should I use with the Pick random [] to []; to determine whether a ball falling down the screen vertically would deflect off a box in the middle of the stage, left or right? It has to deflect, move around it and then continue with it's decent towards the bottom of the screen, the ball cannot go over -175 Y and must stop there. Have been struggling with this, any ideas?

Offline

 

#2 2013-04-26 17:47:29

Pilplup
New Scratcher
Registered: 2013-04-22
Posts: 14

Re: What numbers should I use with the Pick random [] to []?? Help please.

...
...
...
1. ENGLISH pl0x. me no speak your improper grammar talk.
Is this what you're trying to say?

FreaK001 wrote:

What numbers should I use with the Pick random [] to [] to determine whether a ball falling down the screen vertically would deflect off a box in the middle of the stage (making it go left or right)? It has to deflect, move around it and then continue  towards the bottom of the screen, the ball cannot go over -175 Y and must stop there. I've been struggling with this, any ideas?

If that's what you want, just use the bounce block in the motion section...

If it goes straight down, make the random number 1-50 in terms of rotation in degrees so it'll bounce in different sections.

Offline

 

#3 2013-04-26 20:36:39

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: What numbers should I use with the Pick random [] to []?? Help please.

FreaK001 wrote:

What numbers should I use with the Pick random [] to []; to determine whether a ball falling down the screen vertically would deflect off a box in the middle of the stage, left or right? It has to deflect, move around it and then continue with it's decent towards the bottom of the screen, the ball cannot go over -175 Y and must stop there. Have been struggling with this, any ideas?

Well, I suggest putting in the numbers 1 and 2, and then using the (pick random () to () ) in an if statement that controls your ball's movement.

Well, I hope that this helps! Also, hello FreaK001 and welcome to Scratch! I hope that you'll have a great time here!

With regards,

ErnieParke

Last edited by ErnieParke (2013-04-26 20:37:16)


http://i46.tinypic.com/35ismmc.png

Offline

 

#4 2013-04-26 20:46:59

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: What numbers should I use with the Pick random [] to []?? Help please.

Pilplup wrote:

...
...
...
1. ENGLISH pl0x. me no speak your improper grammar talk.
Is this what you're trying to say?

FreaK001 wrote:

What numbers should I use with the Pick random [] to [] to determine whether a ball falling down the screen vertically would deflect off a box in the middle of the stage (making it go left or right)? It has to deflect, move around it and then continue  towards the bottom of the screen, the ball cannot go over -175 Y and must stop there. I've been struggling with this, any ideas?

If that's what you want, just use the bounce block in the motion section...

If it goes straight down, make the random number 1-50 in terms of rotation in degrees so it'll bounce in different sections.

No need to correct grammar, Pilplup.  It's almost flawless, and he may speak English as his native language.  Unless it's a formal paper, there's no need for pure grammar.  If I wrote in pure grammar conventions all the time, it would actually be hard to read.

Welcome, FreaK!  I hope you enjoy your stay here on Scratch!  I would do pick random (1) to (2) and then set the direction accordingly, repeat until off the block, and continue.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#5 2013-04-27 11:34:53

FreaK001
New Scratcher
Registered: 2013-04-13
Posts: 15

Re: What numbers should I use with the Pick random [] to []?? Help please.

Hey guys, thanks for your replies.. Even though that my grammar is very poor (apparently)

I'll add some more info that you guys will need to know, I have to set a variable which I use with the pick random box. I have called this whichWay.

So, I have to set whichWay to pick random [] or [] and use that within my script. I have taken a picture of it so you guys can see, unfortunately I cannot upload my project as I am using Sense and can't seem to open my project within scratch.

http://tinypic.com/r/35kncl0/5

Now, when I run the script. On occasion the ball will deflect off the box left or right at random, this is what I want it to do, but I believe because my ranges of pick random [] to [] are wrong. The problem is, this is the closest I have got to making this happen, using 1 or 2 seems to mess everything up! I'm not far off what I want it to do, it's just finalising it and making it perfect!

Hopefully this is enough for someone to crack, want this out the way.... Thanks anyway to everyone who greeted me to the scratch network, I say hello to you all too!

Offline

 

#6 2013-04-27 12:00:16

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: What numbers should I use with the Pick random [] to []?? Help please.

FreaK001 wrote:

Hey guys, thanks for your replies.. Even though that my grammar is very poor (apparently)

I'll add some more info that you guys will need to know, I have to set a variable which I use with the pick random box. I have called this whichWay.

So, I have to set whichWay to pick random [] or [] and use that within my script. I have taken a picture of it so you guys can see, unfortunately I cannot upload my project as I am using Sense and can't seem to open my project within scratch.

http://tinypic.com/r/35kncl0/5

Now, when I run the script. On occasion the ball will deflect off the box left or right at random, this is what I want it to do, but I believe because my ranges of pick random [] to [] are wrong. The problem is, this is the closest I have got to making this happen, using 1 or 2 seems to mess everything up! I'm not far off what I want it to do, it's just finalising it and making it perfect!

Hopefully this is enough for someone to crack, want this out the way.... Thanks anyway to everyone who greeted me to the scratch network, I say hello to you all too!

Well the issue I see with your script is that sometimes you don't turn a full 90º due to the pick random you've chosen. So to fix this, we'll either need to alter your variable or introduce a script. The first possibility is to set (whichWay) to:

(((pick random (1) to (2)) - (1.5)) * (180))

Basically, this script picks either -90 or 90. It picks nothing else.

The other possibility wouldn't require the variable (whichWay), and would be simpler. So, this would be the base:

if <(pick random (1) to (2)) = (1)>
 Do something...
else
 Do something else...
end

I'll let you fill in the blanks.

With regards,

ErnieParke


http://i46.tinypic.com/35ismmc.png

Offline

 

#7 2013-04-27 12:11:12

FreaK001
New Scratcher
Registered: 2013-04-13
Posts: 15

Re: What numbers should I use with the Pick random [] to []?? Help please.

ErnieParke wrote:

Well the issue I see with your script is that sometimes you don't turn a full 90º due to the pick random you've chosen. So to fix this, we'll either need to alter your variable or introduce a script. The first possibility is to set (whichWay) to:

(((pick random (1) to (2)) - (1.5)) * (180))

Ernie, thank you for your quick reply. I have to use the variable as part of my script, I have done the above however no luck, as it only bounces to the right.  sad

Offline

 

#8 2013-04-27 12:29:14

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: What numbers should I use with the Pick random [] to []?? Help please.

FreaK001 wrote:

ErnieParke wrote:

Well the issue I see with your script is that sometimes you don't turn a full 90º due to the pick random you've chosen. So to fix this, we'll either need to alter your variable or introduce a script. The first possibility is to set (whichWay) to:

(((pick random (1) to (2)) - (1.5)) * (180))

Ernie, thank you for your quick reply. I have to use the variable as part of my script, I have done the above however no luck, as it only bounces to the right.  sad

Oh, wait... I forgot to point out another issue with your script. Along with the changes I suggested above, you have to move your [change [whichWay v] to ()] block into your if so that it looks more like this:

if (touching color [#FF0000] ?)
 set [whichWay v] to ()
 Scripts...
end

The reason why you have to do that is that if you don't, then the variable (whichWay) will stay the same and your ball will always move in the same direction. Adding in this change should fix that issue.

With regards,

ErnieParke


http://i46.tinypic.com/35ismmc.png

Offline

 

#9 2013-04-27 15:58:29

FreaK001
New Scratcher
Registered: 2013-04-13
Posts: 15

Re: What numbers should I use with the Pick random [] to []?? Help please.

Still having problems, gonna come back to it I think..

Offline

 

Board footer