Creation of games with Micro:bit and MakeCode

Micro:bit 23-04-23
486 0

Introduction

Micro:bit is a small programmable computer that can be used to create a variety of games and interactive experiences. MakeCode is an online platform that provides a simple and intuitive way to program Micro:bit.

Here are some game ideas you can create with Micro:bit and MakeCode:

  1. Reaction game: Create a game where players have to press a button as soon as they see a specific image or hear a sound. Use the Micro:bit's built-in accelerometer to detect when the board is shaken and use that as a trigger.
  2. Maze game: Create a game where players have to navigate through a maze using the Micro:bit's buttons or accelerometer. Use the LED matrix to display the maze and the player's position.
  3. Simon says game: Create a game where the Micro:bit plays a sequence of colors or sounds and the player has to repeat it back. Use the LED matrix and the Micro:bit's speaker to display the sequence and provide feedback.
  4. Pong game: Create a simple version of the classic Pong game where players use the Micro:bit's buttons to move paddles and bounce a ball back and forth.
  5. Whack-a-mole game: Create a game where players have to hit a button as soon as an image of a mole appears on the LED matrix. Use the Micro:bit's accelerometer to detect hits and keep score.

Play dice with Micro:bit

Jeu de dé

Playing dice generally refers to the act of rolling dice as a form of entertainment or for gambling purposes. Dice games can involve one or more players and can be played with various combinations of dice, depending on the specific game. Some popular dice games include Yahtzee, Farkle, and Craps. Playing dice can be a fun and social activity, and it can also involve elements of strategy and probability.

In the MakeCode programming environment for Micro:bit, there is a block of code called "shake" that detects when the Micro:bit board is shaken. This can be useful for rolling the dice.

We will also use the instruction choose pick random (0) to (10) from the Math menu, in which you can choose the range of the numbers. We will modify the previous instruction to randomly display a number between 1 and 6 and use the show LEDs instruction to draw the dice on the display of the Micro:bit board.

When the card is shaken, one of 6 numbers (1-6) is randomly selected. It is therefore necessary to define a variable named 'number' which will contain a number between 1 and 6.

Note: To run the game on the simulator, press the white Snake dot.

MakeCode program dice

Play the rock-scissors-paper game with Micro:bit

rock-scissors-paper game

Rock-scissors-paper is a hand game played by two people. The game consists of each player making one of three shapes with their hand: a closed fist representing "rock," an open hand with fingers extended representing "paper," or a fist with the index and middle fingers extended representing "scissors."

The game is typically played with a countdown, during which both players make their choice of rock, paper, or scissors. After the countdown, both players reveal their choices simultaneously, and the winner is determined based on a set of rules:

  • Rock beats scissors (rock crushes scissors)
  • Scissors beats paper (scissors cut paper)
  • Paper beats rock (paper covers rock)

If both players choose the same shape, the game is a tie and is usually played again.

The game can be played as a single round or as a best-of-three or best-of-five series. It's a simple and fun game that can be enjoyed by people of all ages.

The Micro:bit card allows you to play multiple games, such as the classic rock-scissors-paper. When the card is shaken, one of three choices (rock, scissors, paper) is randomly selected. It is therefore necessary to define a variable which will be a number between 0 and 2, which will give three possible choices. For example :

  • 0 for rok

  • 1 for scissors

  • 2 for the sheet

Note: To run the game on the simulator, press the white Snake dot.

makecode rock-scissors-paper game

Flip a coin with Micro:bit

Jeu pile ou face

The principle of the flip a coin game is quite simple. Two players agree to flip a coin, and one player chooses heads, while the other chooses tails. The coin is flipped, and if it lands on the chosen side, the player who chose it wins.

The game can be played with any type of coin, but typically a standard two-sided coin with heads on one side and tails on the other is used. The game is often used as a simple way to make a decision or to determine which player goes first in a game or activity.

It's important to note that the outcome of a coin flip is completely random and cannot be predicted. Therefore, the game is considered fair, and both players have an equal chance of winning.

Here is a MakeCode program that simulates the flip a coin game: when the card is shaken, a random number is displayed on the Micro:bit card

Note: To run the game on the simulator, press the white Snake dot.

makecode flip-a-coin game

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info