I just posted my first project ("Pong!") which was a lot of fun to figure out in Scratch. I noticed, however, that I was forced to use a lot of global variables and broadcast messages in order to accomplish things that would have been easy had I had access to any sprite's state from another sprite.
For example, for my computer's paddle to follow the pong ball (named "Ping"), I had to have the paddle broadcast "Ping Y Position" and wait. When the ball sprite received that message, I had it set a global variable to its y position. Then the computer paddle, returning from its wait, could act based on the global variable.
This would have been much easier if there had been a "quantity" block (the type with rounded edges) named "____'s ____". The first blank could be a drop-down menu of all sprites. The second would then be a menu of the various state variables associated with a sprite, such as x position, y position, etc. I would not have had to rely on the global-and-messaging kludge above--instead I could have had one block that said "Ping's y position".
I don't think such an addition would be overly confusing if handled properly. It's only one block, after all. It should probably go either in the "variables" screen (at the very top, so it's always easily found), or in the "sensing" screen after the three mouse blocks. This would expose a very object-oriented concept, which to me seems beneficial, at very little cost. Of course, with the addition of dynamic object creation the picture becomes slightly more complicated because a simple drop-down won't suffice, but you'll already have to solve that problem with existing blocks like "point towards ___".
The accessible state variables should include the following as a minimum:
x position
y position
direction
size
pen color
pen size
pen shade
Perhaps they could also include the private variables for that sprite.
Offline
Hmmm, IMHO, let's not forget that Scratch is meant to be a simple language to teach young people the basics of programming. It's easy to witness the absence of any programming structure in most projects on this site, a sign that tells me that the basics have not been absorbed yet. Having myself experienced how hard it is to explain a 6-year old what are variables and how to use them, I vote against cluttering Scratch with advanced concepts available in other, more mature programming environments.
Offline
Yes I agree with you. It should be easier to refer to a sprites attributes like _x and _y.
Offline
The variable displays already use the "sprite's variable" convention, and it would be convenient to allow that wherever variables are used. Pulldown lists for
"my | shared| sprite's" and "variable" would reduce the number of blocks for variables, especially if all the sprite's state (x, y, color, costume, direction) were available that way.
Last edited by kevin_karplus (2007-10-03 00:01:08)
Offline
LeBurt wrote:
Hmmm, IMHO, let's not forget that Scratch is meant to be a simple language to teach young people the basics of programming. It's easy to witness the absence of any programming structure in most projects on this site, a sign that tells me that the basics have not been absorbed yet. Having myself experienced how hard it is to explain a 6-year old what are variables and how to use them, I vote against cluttering Scratch with advanced concepts available in other, more mature programming environments.
Yes maybe but I wouldn't underestimate a 6 year old. OO concepts are meant to be easy to understand. It is good to have the concepts such as direct message passing between objects. I think this is more intuitive than broadcasting. Also a newbie doesnt need to use all the possible language features at once. I certainly think there is scope to encourage older children like me to use scratch :-)
Offline
I think that "send to (self|all|specific sprite)" is as simple to understand as "broadcast" and opens up programming possibilities that require complicated work-arounds if you have only "broadcast".
Offline