Problem Set 0 - Scratch ๐Ÿˆ

Problem Set 0 - Scratch ๐Ÿˆ

Scratch - Week 0 of CS50x 2022 โœจ

ยท

3 min read

Here starts our Programming Journey with CS50x! After watching the video, we were tasked to make our own video game in Scratch.

For those unfamiliar with Scratch, it is a visual programming language developed by MIT that can be used to create stories, animations, art, music, and games. The user interface is very easy to understand and use which can help introduce even kids to programming. Because it is a visual programming language, it utilizes coding blocks that can be dragged, dropped, and connected to other blocks to make programs.

When creating a project to be passed to CS50x, the following requirements should be met:

  • Your project must use at least two sprites, at least one of which must not be 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 conditional, at least one loop, and at least one variable.

  • Your project must use at least one custom block that you have made yourself (via Make a Block), which must take at least one input.

  • Your project should be more complex than most of those demonstrated in the lecture (many of which, though instructive, were quite short) but it can be less complex than Oscartime and Ivyโ€™s Hardest Game.

And here's the game I made! It is called Fruit Dash, as it is inspired by Fruit Ninja and Muse Dash.

When starting the game, the player can press the keys 1, 2, or 3 to set the difficulty. 1 is easy, 2 is medium, and 3 is hard. Then the player can press the UP or DOWN key to slash the fruits and earn scores in 30 seconds.

Press here to see the code of each sprite!

The game had a total of 9 sprites.

Four of these is the character the player is controlling. When a certain key is pressed or a certain event has happened, a specific animation will play out.

One of the sprites is the fruit. This fruit sprite contains many different types of fruit the player can encounter. The code for the difficulty which changes the speed the fruits approach the player, can also be found in this sprite. The code utilizes if-else statements and a random number between 1 and 2. If the random number is equal to 1, the fruit will appear on the lower side of the game, else it will appear higher.

The two circles, on the other hand, check if the fruit and the circle touch when either the UP or DOWN key is pressed.

And lastly, the title screen. When the flag is pressed, the music will start to play. And when one of the difficulty keys is pressed, it will start the 30-second timer and hide the title screen. When the timer ends, the score will be printed out and the player will be asked to press the flag again to restart the game.

Thank you for reading and that is scratch for you!

ย