Programming with Scratch

The first week of CS50x is an introduction to the course and an introduction to thinking in the same way as a computer. As an introduction to programming and the logical steps that a computer takes I was introduced to an online programming environment called Scratch. Developed by MIT, it allows for users with little or no prior programming knowledge to construct simple scripts and programs using a visual interface.

Scratch works by offering the user a series of ‘puzzle pieces’ to create functions, variables and loops. Some of these pieces are shown below

Screen Shot 2017-04-23 at 21.37.01

Problem Set 0

The task set out in problem set 0 was simply to play around with scratch and get a feel for how the logic of programming works and then submit a program, the specifications for the program were:

  • Your project must have at least two sprites, at least one of which must resemble something other than a cat.
  • Your project must have at least three scripts total (i.e., not necessarily three per sprite).
  • Your project must use at least one condition, one loop, and one variable.
  • Your project must use at least one sound.

For this task I decided to create a mini game in which a character has to move across three screens to collect beach balls in order to win. This is a much simpler concept than I had originally wanted, I had originally wanted to add enemies into the game, but the scripts for these were proving a little too complicated at the time for them to be included in a time effective manor.

The main difficulty was working around the script which changes the backgrounds. This script detects when the main character sprite was at the edge of the screen, switches the background to the next one in the sequence and then moves the character to the other side of the screen to give a scrolling background effect. Actually getting the program to do this wasn’t too difficult but getting the beachballs that were placed in the game to reappear when returning to the background only if they hadn’t been collected proved to be something I couldn’t figure out.

The final version of my project is below: