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

#1 2007-05-20 16:16:58

albertus
Scratcher
Registered: 2007-05-20
Posts: 3

Touch Edge triggers erratic behaviour

Hello, all.

First of all, and because it is my first post, Many thanks to Scratch's developer team for doing it! I worked with LOGO long ago, but this is acres more fun.
Having said that, and because I feel it is an excelent tool I will pass to my own children's computer class teachers, I also feel urged to contribute to it's development.

I have detected a bug with a little game called "Space Blawrs", find it here
http://scratch.mit.edu/projects/albertus/4630

So I have a script to reset the asteroid when it touches the edges of the screen, but it doesn't, or does so in an erratic way.

Please try it out and if you can improve this behaviour it would be nice.
I have more things to share, but I will do so on the sugestions thread.

3 cheers to MIT and Scratch's develolopers from Lisboa, Portugal.

Offline

 

#2 2007-05-21 09:41:58

Canthiar
Scratcher
Registered: 2007-05-16
Posts: 100+

Re: Touch Edge triggers erratic behaviour

You have this for the movement:

Forever
   Move (1) steps

Which it will never break out of.  You should probably change it to

Repeat until  < not < touching [ edge ] > >
  Move (1) steps

Offline

 

#3 2007-05-28 03:35:55

albertus
Scratcher
Registered: 2007-05-20
Posts: 3

Re: Touch Edge triggers erratic behaviour

Hello.
your solution, elegant as it is, do not work because it thinks the edge is at middle screen...

thanks

Offline

 

#4 2007-05-28 04:21:20

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Touch Edge triggers erratic behaviour

The problem is that you have three instances of "forever move 1 step"

Keep only the first one on your first when-green-flag script.

Change the other green-flag script to

when green-flag clicked
forever
   wait pick random ...
   if touching edge
     goto random ..
     point in direction random ...
     show

This seems to be the minimal change that will do pretty much what you want.
Note: I put the wait before the if-touching-edge so that you don't get stuck on the top edge.

Offline

 

#5 2007-05-28 04:41:27

Canthiar
Scratcher
Registered: 2007-05-16
Posts: 100+

Re: Touch Edge triggers erratic behaviour

That looks like it works too.  I made the change I mentioned above and it seemed to work for me.

[when green flag clicked]
  [forever]
    [ if <touching [edge] ? > ]
      [ go to x: ( pick random (-230) to (230) ) y: (195) ]
      [ point in direction (pick random (140) to (220) ]
      [show]
      [ repeat until < not < touching [ edge ] ? > >
        [ move (1) steps ]

The forever loop keeps the edge collision check from running a second time so I think that is the important thing to get rid of.

Offline

 

Board footer