-continued from previous comment- No pretension of polymorphism. If I pretend, it seems like a good visible way to introduce the concept that the behaviors of objects are controlled by methods and properties. --- As an aside, this is the worst text editor I have ever seen. It keeps jumping back to the beginning.
Thanks for answering, Dick! Interesting point of view, but I'll probably keep disagreeing (more for argument's sage, however, since in practice the disctinction class var / global var doesn't make any difference in Scratch). You're right about the text editor having gotten a lot worse due to the new character counter (especially on slow old machines like mine). Hint: It seems to be better when replying ;)
Jens, class vars vs instance vars: Truth is somewhere in between. I need to get students used to common object terminology. Justification for the use of class vars and instance vars: Pretend like sprites are objects with methods (move and turn) and properties (instance variables) controlling their behavior. Similar to Alice where there are classes of a sort, but hidden from the programmer. Programmer can only create instances of existing classes. -to be continued in next comment-
Hey Dick, this is in reply to your question about my replies. I really *did* reply that often. You can view these replies by clicking on the respective "view all replies" links (In fact, I just found out about this myself...)
Something else that might make your script easier to read (and to understand) could be to just use the plain "x position" reporter blocks from the boy sprite's motion category when determining bX and likewise bY instead of the more complex (and in this case redundant) "x position of boy" block from the "sensing" category (That sensing block is really only needed if you want one sprite to "peek" at another sprite's local property/variable).
Again, thanks for the feedback. I'll take a look at your suggestion. As you can see, I'm just getting my feet wet with Scratch. I have a question for you. My message queue says that I have five comments from you and one from AddZero. However, I only see two comments from you. Did you really make five comments and some of them are hidden, or is there an error in the message queue?
Thanks,
Dick Baldwin
Nice demo of perspective and pseudo 3D! I especially like how the steps become smaller as the sprite retreats to the horizon. Why do you use a "repeat 1000" loop instead of a foreever loop, or two threads with something like "repeat until touching mousepointer"? Another thing: Shouldn't the variables be all local ones (possibly except mY indicating the horizon), as they don't affect the stage (which doesn't have any scripts) at all?
Thanks for the feedback.
"Why do you use a "repeat 1000" loop" - Just a safety thing. In case it is running and I go off to do something else such as check my email and forget to come back, I don't want it running forever stealing machine cycles and slowing down whatever else I am doing.
"Shouldn't the variables be all local ones?" Yes. Just laziness on my part, which is pretty bad because I tell my OOP students frequently that they shouldn't use class variables out of laziness.
This project is being published as part of a series of tutorial lessons (Google dick baldwin toc) under the heading Computer Programming for Homeschool Students. Click the green flag to start or restart the program.
Learn how to write an interactive animation that places a walking sprite on a moonscape. The sprite walks toward the mouse pointer and freezes in place if it catches the mouse pointer. It resumes walking again when the mouse pointer is moved.
Perspective computations are used to create a 3D effect with the sprite becoming smaller and smaller as it walks away from the camera.
Scratch Version 1.2.1 or later is required.
Comments
You need to be logged in to post comments
Add a Comment
nice!
-continued from previous comment- No pretension of polymorphism. If I pretend, it seems like a good visible way to introduce the concept that the behaviors of objects are controlled by methods and properties. --- As an aside, this is the worst text editor I have ever seen. It keeps jumping back to the beginning.
Thanks for answering, Dick! Interesting point of view, but I'll probably keep disagreeing (more for argument's sage, however, since in practice the disctinction class var / global var doesn't make any difference in Scratch). You're right about the text editor having gotten a lot worse due to the new character counter (especially on slow old machines like mine). Hint: It seems to be better when replying ;)
(view all replies)Jens, class vars vs instance vars: Truth is somewhere in between. I need to get students used to common object terminology. Justification for the use of class vars and instance vars: Pretend like sprites are objects with methods (move and turn) and properties (instance variables) controlling their behavior. Similar to Alice where there are classes of a sort, but hidden from the programmer. Programmer can only create instances of existing classes. -to be continued in next comment-
Hey Dick, this is in reply to your question about my replies. I really *did* reply that often. You can view these replies by clicking on the respective "view all replies" links (In fact, I just found out about this myself...)
This works pretty well. Nice work!
Something else that might make your script easier to read (and to understand) could be to just use the plain "x position" reporter blocks from the boy sprite's motion category when determining bX and likewise bY instead of the more complex (and in this case redundant) "x position of boy" block from the "sensing" category (That sensing block is really only needed if you want one sprite to "peek" at another sprite's local property/variable).
Again, thanks for the feedback. I'll take a look at your suggestion. As you can see, I'm just getting my feet wet with Scratch. I have a question for you. My message queue says that I have five comments from you and one from AddZero. However, I only see two comments from you. Did you really make five comments and some of them are hidden, or is there an error in the message queue? Thanks, Dick Baldwin
Nice demo of perspective and pseudo 3D! I especially like how the steps become smaller as the sprite retreats to the horizon. Why do you use a "repeat 1000" loop instead of a foreever loop, or two threads with something like "repeat until touching mousepointer"? Another thing: Shouldn't the variables be all local ones (possibly except mY indicating the horizon), as they don't affect the stage (which doesn't have any scripts) at all?
Thanks for the feedback. "Why do you use a "repeat 1000" loop" - Just a safety thing. In case it is running and I go off to do something else such as check my email and forget to come back, I don't want it running forever stealing machine cycles and slowing down whatever else I am doing. "Shouldn't the variables be all local ones?" Yes. Just laziness on my part, which is pretty bad because I tell my OOP students frequently that they shouldn't use class variables out of laziness.
(view all replies)