Scratch Sprites - What Data?
The Obvious
When I started thinking about Scratch Sprites, to me, the most obvious data that we keep track of is the dataabout its location and direction. In fact, the first thing I thought about was the data that is actually displayed for every sprite when you use Scratch:
In other words, we are pretty sure that a Scratch Sprite has:
- Name - as a string
- xLocation - as an integer (assumed to be -240 to +240)
- yLocation - as an integer (assumed to be -180 to +180)
- size - as an integer (assumed to be 0 to 100)
- Direction - as an integer (assumed to be -180 to +180)
- Show - as a Boolean
The "Somewhat Obvious"
The next set of things that came to me weren't as obvious - they weren't on the front page of the information about each sprite. But it didn't take me much thinking to remember that each sprite also knows:- Costumes - as a list of named images
- Sounds - as a list of named audio files
The more advanced/less visible data
Finally, I started looking at all of the actions that were available to each sprite by going down the code blocks. As I did that I realized that there are several additional pieces of data that each sprite has to remember.
- Rotation Style - Selected from a set of three options
- Current Costume
- Current Color effect
- Current Fisheye effect
- Current Whirl effect
- Current mosaic effect
- Current brightness effect
- Current ghost effect
- Current layer
- Pitch effect
- Volume effect
- Plus some additional things you could elect to add via make a Variable or make a List
Final Class Diagram
One of the things that programmers often do is draw "Class Diagrams" which represent what a class knows and can do. A Class Diagram for the Sprite class which only focuses on the six main pieces of data would look like: