Learning Scratch By Reading and Analyzing Others Project – BeatCube! Part I

There are lots of excellent projects in the Scratch community. As an instructor of Scratch learning, I am often amazed by the creative ideas and exquisite design of those mini games. I am also surprised that many interesting objects are developed by teenagers.

Today, I will analyze another project called BeatCube. It is different from many other platform games on Scratch. It is kind of like a 3-dimensional game, which attracts me to see its code inside. Player needs to uses the arrow keys or ASWD keys to move the blue cube away from those red cubes as fast as possible. The matrix of cubes is aligned at an angle of 45 degree on the stage, increasing the difficulty for the player to tap the proper arrow keys.

The idea of this project is really special, but when I read its code, I also notice some code design problem. Now, let us learn its code with a critical mind and suggest a better method for some code segments.

BeatCube! Game

Backdrop’s Code

The code of backdrop is very normal. It displays different backdrop music under different scenarios. The author controls music volume to make it fade away gradually.

Key Sprite’s Code

Key Sprite shows how to use arrow keys to play the game. The author uses ghost effect to make this sprite twinkle at a short interval.

“When I receive Menu” block defines the behavior of the Key Sprite at the menu selection stage.

“When I receive Play” event defines the behavior of Key Sprite when the user is playing the game.

The code here looks a bit strange. For this game, the program will throw out Play event again after claiming the Death. Under that condition, the previous clone is still existing, resulting into two clones showing on the stage. Therefore, the author deletes one clone in one event of “When I receive Play”. Actually, it is not a good way to implement this function, which makes the code messy. The author does not need to create a clone for such an auxiliary sprite. A simpler way is just to change its costume, like the updated version shown below.

An Updated Version for Key Sprite

Game Cover Page and Ending Page – Thumbnail Sprite’s Code

Thumbnail sprite is not a key sprite, either. It shows the cover page and end page of the game. The reason I list it here is because it has a special design. When the program is running, it will always reset timer. So what is the purpose of writing “When timer>0”?

If you tap on the Sensing category and check “timer”, it will appear on the stage. When you stop the program by clicking the red button, the timer still runs. The author of this game is using this property of timer to set an ending game page after program stops.

So what if the game does not set ending game page? That is also fine. The ending page will appear like the the right image shown below.

Till now, I finish Part I of introducing the auxiliary sprites. In the next part, I will analyze its key sprite, Land sprite, and give a better version for some code segment.

Enjoy the coding!

Note: All the analysis articles are copyright products of http://www.thecodingfun.com. Anyone re-posting them should credit author and original source. Anyone using them for commercial purposes or translating them into other languages should notify TheCodingFun and get confirmation first. All Rights Reserved.

2 thoughts on “Learning Scratch By Reading and Analyzing Others Project – BeatCube! Part I

  1. Pingback: Learn Scratch by Remixing Others’ Project – BeatCube! remix Part 2 – Coding Courses Designed for Kids

  2. Pingback: Learn Scratch by Remixing Others’ Project – BeatCube! remix Part 1 – Coding Courses Designed for Kids

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.