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

#1 2013-04-22 18:27:20

le_me26
New Scratcher
Registered: 2013-04-21
Posts: 5

Heeeeellllpppp!!!! :)

Hey alll.... im completley stuck and as much i was convinced i will manage it myself i decided that i cant kill my mind for any longer...  smile

So im doing this awesome project of 120 balls (1 at the time) falling true the peg of many cubes and each time or most of the times the path is different. So whenever the ball reached the edge it leaves a stamp. In case there is another ball falling into the same point the ball should stay on top of the other ball by changing the position lets say y 10...
so i got the thing working to the part that i get 2 balls on top of each other by using the block of #If touching the (color)# but for some kind of reason every other ball what falls to the same point dosent stop on top but falls to edge..  hmm

Here is the scrip...it would be great if someone could have a quick look and could suggest me what em i doing wrong.. Thanks upfrony  smile

when_green_flag_clicked
{
   clear
   repeat 120 
   {
      go_to_x: 0 y: 170
      show
      repeat 8 
      {
         repeat_until (touching_color [FF0000]?) 
         {
            change_y_by -1
         }
         set whichWay to (pick_random 1 to 2)
         if (whichWay = 1)
         {
            move -10 steps
         }
         if (whichWay = 2)
         {
            move 10 steps
         }
      }
      repeat_until ((y_position) = -175) 
      {
         change_y_by -1
      }
      if (touching_color [0042FF]?)
      {
         change_y_by 10
         stamp
      }
      else
      {
         stamp
      }
   }
}

Offline

 

#2 2013-04-22 18:45:03

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

Re: Heeeeellllpppp!!!! :)

Okay, so I see the problem. In your script, you have this:

      repeat_until <(y_position) = (-175)>
      {
         change_y_by -1
      }
      if (touching_color [#0042FF]?)
      {
         change_y_by 10
         stamp
      }
      else
      {
         stamp
      }

The problem with that is that you're going to continue falling till you hit the edge, and no matter how many balls there are, you either going to straight away stamp or move a tiny bit, then stamp. Instead, try changing the repeat's conditional into this:

      repeat_until < <(y_position) = (-175)> or (touching color [Color of Ball] ?) >
      {
         change_y_by -1
      }
      if (touching_color [#0042FF]?)
      {
         change_y_by 10
         stamp
      }
      else
      {
         stamp
      }

The change that I've made allows the ball to stop once it hits another one.

Well I hope that this helps!

With regards,

ErnieParke


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

Offline

 

#3 2013-04-22 19:12:47

le_me26
New Scratcher
Registered: 2013-04-21
Posts: 5

Re: Heeeeellllpppp!!!! :)

OMG!!! Thank you so much..thing works now perfectly and i have a lesson now...i should think deeper  smile ) One more time so much thank you you saved me..  smile

Offline

 

#4 2013-04-22 20:54:34

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

Re: Heeeeellllpppp!!!! :)

le_me26 wrote:

OMG!!! Thank you so much..thing works now perfectly and i have a lesson now...i should think deeper  smile ) One more time so much thank you you saved me..  smile

Well, once you get used to Scratch, things will become easier. I promise you that. ;)

Anyhow, you're welcome! Remember, if you have any other problems, ask away.

With regards,

ErnieParke


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

Offline

 

Board footer