Discuss Scratch

retro_person
Scratcher
100+ posts

Implementation of Advanced Functions in Early Versions of Scratch

Many of the very early versions of Scratch lack many advanced functions commonly used in more advanced projects. For example, the October 2003 version of Scratch lacks:
  • A rounding operator
  • A floor operator
  • Cosine/sine operators
  • A square root operator
  • A block to clear all pen trails
  • A block to set the pen color to a precise value (instead of just using the built-in color picker)
  • Any sort of list/array manipulation (through blocks)
However, I have (so far) been able to implement all of these functions in this version. Because this version supports the creation of custom “scripts” (equivalent to My Blocks in modern versions), as well as being able to use these “scripts” as operators (and have them return values), it is possible to create most of these functions. Additionally, the
answer []:: control
block in this version (equivalent to a return function in most other programming languages) actually evaluates the input, rather than simply returning it. Therefore, since this version of Scratch is written in Squeak, it is possible to “inject” Squeak code into this block, which can be used to implement blocks such as “clear pen trails” by calling the internal clearPenTrails function in this version. This method can also be used to (with some difficulty) perform array manipulation in Squeak, and then store those arrays in variables (and read from them). Lastly, by defining a Squeak color value, it is possible to apply a specific color to the pen (thanks to CST1229 for implementing this).

As for a potential use of these advanced functions, implementation of a raytracer (by using Geotale's tutorial) in this version of Scratch is, with some difficulty, now possible (with some additional workarounds to map the different coordinate system of Scratch11Oct03 to that of the current version). The lighting still seems to be a bit off (brightness and saturation blocks also had to be worked around), and the speed is rather slow (this single render took at least a few hours, if I recall).

(If anyone is interested in checking out the project itself, I've uploaded it to MediaFire here. This project features implementations for all of the functions listed at the start of this post, although not all were necessarily used in the raytracer's code itself.)

Powered by DjangoBB