Monday, March 28, 2016

My Scratch Project

Ta-da! Here's the Scratch project I made this week: https://scratch.mit.edu/projects/102693993/

As you can tell, I'm still a gigantic nerd!
This project turned out exactly how I wanted it to, and I'm very proud of it! So, what did it take for me get so invested in a programming project? Papert and Resnick et al. are right; making it personally meaningful and developing a relationship with the project really helps! The open-source nature that allows for "looking inside" and remixing Scratch projects also helped me reach my goal.

The project is a remix of a "fruit catching game," only instead of fruit, you try to catch Star Wars: The Force Awakens characters in a trashcan. You get points when you catch the movie's villain Kylo Ren (and lots of points if you catch the wild card, Anakin). You lose points if you catch Rey or Finn, because they are heroes and they don't belong in the trash! Every time you catch a character, you see a little message. The game starts out with 10 points. If you lose all 10 points, then it's game over. If you last all 105 seconds without losing all your points, then you win!

Almost every decision I made here reflects some sort of joke about the Star Wars fandom, and each joke has multiple layers of meaning. I intentionally made the project to include those jokes and because I knew other Star Wars fans would enjoy them. There's nothing I and the fandom love more than making fun of our problematic favorite wannabe-Sith lord Kylo Ren. My choice of "trash" as the theme has a long history in fandom. I'm not sure of its origins, but when a fan calls a character or a romantic pairing they like "trash," they're acknowledging both the problems with the character/pairing and their own silliness in liking them. So they're calling both the character/pairing and themselves trash. In addition, I've seen fannish blog posts calling Kylo Ren a "trashcan" because he wears a "trashcan" on his head, and he's also a whiny brat who needs to learn a lesson, so it's even more appropriate to associate him with trash. There are also these two Tumblr images that further inspired the idea, which I credited in my description of the project. All of the things Kylo Ren says when the trashcan catches him are somehow based on his character or are plays on his actual lines. They are all about how he belongs in the trash. Finn and Rey's lines are similar, except they chastise the player for putting them in the trash. Poking some fun at my favorite fandom right now was a great way to make a personal connection to the project and to motivate me to do it well.

As for the process, I was really grateful that Scratch lets you remix other projects. There's no way I could have coded this whole game from scratch! (pun intended) I searched for "catching game" on the Scratch website and found this game, called "fruit catching game." I thought my remix would mostly involve design work, i.e., modifying the sprite's costumes to be the Star Wars characters instead of fruit and junk food, replacing the player character with a trashcan, switching out the background for a more Star Wars-y one, etc. I also added one "say for 1 sec" block to each character sprite, so they would react with a speech bubble when they touched the trashcan sprite. All this was quite simple, especially since I've worked with Scratch a little in the past.

However, there were some things about the original fruit catching game that I didn't like much. For instance, all the fruit that scored you points (i.e., Kylo Rens in my game) fell from the left side of the screen, while most of the junk food that lost you points (Finn and Rey in mine) fell on the right, so it was too easy to just stay on the left until time was up, and avoid most of the junk food. To resolve this over-simplicity, I had to tinker around with the x-positions of the sprites. Just like the kids in Mindstorms tried different numbers for angles to see what would happen to the Turtle in LOGO, I also used trial and error on the x-position numbers, until I figured out that the negative numbers were for the left side of the screen, and the positive for the right, just as you would expect from a coordinate plane. I also found that the numbers went pretty high up, into the hundreds. I modified some of the numbers, but left others the same. It's still not quite as random as I'd prefer, but it's okay.

I also didn't like that the original game simply said "Game over" at the end without telling you if you had "won" or not, no matter how many points you had collected. The "Game over" made it sound as if you always lost. I wanted to make it so you really could lose if your score got too low, but if you got enough points by the end of the 105-second timer, you would win and see a "Congratulations" message. This required more advanced programming than I had ever done before in Scratch. I looked at the existing blocks on the stage. At first I tried to use the "lives" variable, but I quickly realized that the original programmer hadn't specified a real role for "lives," so I deleted that variable and all of its associated blocks. I used the score instead. To change the score to start from 10 rather than 0 (making it so you kind of have 10 "lives"), I had to change the starting score on all sprites to 10. This took some exploring to figure out why changing it for only the primary sprite (the trashcan) wasn't effective. I changed the original "Game over" message to "Congratulations! You took out the Star Wars trash!", and still had it appear at the end of the timer's countdown, but only if the score was greater than 0. This required the use of an "If-then" block and a green "greater-than" (>) operator. To make the "Game over" message appear when your score went below 0, I again had to use the "If-then" block and a green operator block, but it was "less-than" (<) this time. After this didn't work, I discovered that you had to drag the score variable into the green operator block, instead of typing the word "score." The last problem I ran into was that the "Congratulations" message would work if you won the game, but the "Game over" message that would stop the game before you reached the end of the countdown would not work. I clicked on the little question mark button (Block help) and opened the help text for the operator block. In looking at the example code they had there, I realized I had forgotten a "forever" loop! What a rookie mistake! I've programmed e-textile lights to flash forever so many times that I should have known better. After I added the "forever" loop to the "Game over" code, it finally worked. The "Congratulations" code doesn't have a "forever" loop. Instead it's programmed to appear after a "wait for 103 secs" block.

I really saw the benefits of Scratch's "remix" function. I learned things about variables and operators that I probably never would have if there were not already examples of them in the project I remixed. If I'd started from scratch, I probably would have made a much simpler project and would have stuck to those blocks I was already familiar with. Being able to remix, and having motivation through a personal connection to the topic motivated me to go beyond my comfort zone. This is the way learning should always work!

No comments:

Post a Comment