
Hungry Square Game
The goal is for the Hungry Square (Hungry for short) is to eat as many foods as possible within one minute. Hungry stays on the left but moves up and down, in response to the arrow buttons, to be in line with a food stream. Food streams come from the right in one of three vertical positions: middle,, top and bottom as shown in the screenshots below. The game score is the percentage of launched foods that are eaten.
The Code
Big Picture of Game Flow
The overall game flow is shown in the screenshot below.

The on-start block lays out the game screen and initializes key variables. Game action is initiated by two on-game-update blocks, which ran at random intervals. The top on-game-update block changes the food steam to either top, middle or bottom. The lower on-game-update block, launches a food in the current stream. The random intervals causes the spacing between foods to vary. The on-countdown-end block ends the game after one minute.
User interaction with game is by using the up and down arrows to change the Hungry’s vertical position.
The overlap event block (on the right) is triggered when Hungry intersects a food. This event increases the score, plays a sound and opens then closes Hungry’s mouth.
Supporting Code
The functions shown in the screenshot below are called from the on-start block and initialize the list of foods to be launched and the notes that are to be played when a food is eaten. The function create_square initializes the two sprites (mouth open and mouth closed) that represent Hungry.

Get the Code
To run Hungry Square, click on the following link: https://makecode.com/_fmfchu0du2kp
Hungry Square will open in a new browser tab. To restart the program, click on the Restart button below the game window.
View, Edit and Download the Code
To view, edit and download the code, click on the Show Code button towards the top of browser to the right of the game name.

Clicking the Show Code button (above) will open the window below. Notice the Show Game button to the right of the game name, will re-open the code window.

Clicking the MakeCode logo button (upper left ) will open an Arcade MakeCode window with the code just as if you had developed it yourself. From this point you can edit, save locally, share and download to other devices (e.g., Meowbit). Enjoy.
iPhone Using Safari Browser
The procedure descripted above works perfectly on the iPhone as shown in the screenshot sequence below. I understand the need for the messages from Microsoft and Apple on these screens, but REALLY they are taking way too much screen real-estate if they are to stay on the screen during gameplay and code development. I have yet to figure out how to dismiss these messages.
You must be logged in to post a comment.