Skip to content

A Python Script to run a funny animation game on a Microbit board

License

Notifications You must be signed in to change notification settings

violincase13/Memory-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Memory-Game

A Python Script to run a funny animation game on a Microbit board

First, a list of variables was created called firstCommandsList in which are stored the initials of the first commands that can be executed: select difficulty level (D), respectively close (X). When the microbit is activated, items from the first command list are randomly displayed as characters (basic.show_string(""+(firstCommandsList._pick_random()))). If the A and B keys are pressed simultaneously while X is displayed, the exit function (chooseToExit) is called. If they are pressed while D is displayed, the difficulty level selection function (chooseTheDifficultyLevel) is called.

The exit function (chooseToExit) nicely programs the microbit to display the "Bye" message and stops the interaction. The difficulty level selection function (chooseTheDifficultyLevele), like the previous procedure, provides for the creation and memorization of variables corresponding to each level of difficulty (E - Easy; H - Hard) and their selection by simultaneously pressing the buttons A and B. When one of the levels has been selected, its selection function is still called: chooseEasyLevel for the easy level (E), respectively chooseHardLevel for the difficult level (H). If the buttons were not pressed simultaneously, but only separately, the successor command (for A) and the predecessor command (for B) will be displayed.

The commands for selecting one of the difficulty levels (chooseEasyLevel, respectively chooseHardLevel) work on the same principle: variables corresponding to the start (S) and exit (X) options of the game have been created. If, while the letter S is displayed on the screen, the A and B buttons are pressed simultaneously, the game loading function corresponding to the previously selected difficulty level is called (for E - chooseToPlayEasy, respectively for H - chooseToPlayHard) . If only the A/B button was pressed, then the letter corresponding to the successor/predecessor command will be displayed. Analogous if the letter X is displayed, in this case the exit function will be called.

The game loading functions (chooseToPlayEasy / chooseToPlayHard) work according to the following principle: variables corresponding to each image have been created, provided they are displayed for this level, in an appropriate list (EasyImageList / HardImageList). The score value is set to 0. From this list, the images are displayed in order (using a for loop). Later, the message "Now it's your turn to choose the images you've seen" will be displayed, which means the player must remember their order and make pairs of 2 (for easy level) and 3 (respectively for the difficult level), in the initial order of the images. If the player has identified a correct pair (by pressing the A and B keys simultaneously after the images are displayed), then the message "Correct" will be displayed and the score value will increase with 1. If the player choosed a wrong pair, the message "Incorrect" will be displayed. If there are 2 incorrect attempts one after the other, the game will be lost. For this, with each error, the value of a variable called incorrectChoiceCounter will increase with 1. The game will be won when the required number of pairs have been formed (2 for the easy level, respectively 3 for the difficult level). The message "Congratulations!" will appear on the screen.

About

A Python Script to run a funny animation game on a Microbit board

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages