Microbit: Tug-of-War (with 2 Players)
by LouisAttaSaow in Circuits > Microcontrollers
483 Views, 0 Favorites, 0 Comments
Microbit: Tug-of-War (with 2 Players)
![F4M38P9KUQYF6FA.jpeg](/proxy/?url=https://content.instructables.com/F6N/SLY4/KUQYF6FD/F6NSLY4KUQYF6FD.jpg&filename=F4M38P9KUQYF6FA.jpeg)
![microbit.PNG](/proxy/?url=https://content.instructables.com/FGU/DVXM/KUQYF5YQ/FGUDVXMKUQYF5YQ.png&filename=microbit.PNG)
In dit instructable zal er uitleg gegeven worden over hoe je uw eigen spel van "Tug-of-War" kan maken en spelen.
Supplies
![17287-micro-bit_2.0_Board-01.jpg](/proxy/?url=https://content.instructables.com/FTR/AGGF/KUQYF9Q1/FTRAGGFKUQYF9Q1.jpg&filename=17287-micro-bit_2.0_Board-01.jpg)
![Olight-micro-USB-kabel.png](/proxy/?url=https://content.instructables.com/FJJ/ZBW3/KUQYF9ZO/FJJZBW3KUQYF9ZO.png&filename=Olight-micro-USB-kabel.png)
Materiaal: Micro:bit, USB-kabel
Variable Maken
![step1micro.PNG](/proxy/?url=https://content.instructables.com/FLR/BYC3/KUQYF8N2/FLRBYC3KUQYF8N2.png&filename=step1micro.PNG)
Eerst en vooral moet je een variabele aanmaken. Variabelen zijn handig als het komt met berekeningen en kan verschillende elementen aannemen.
Klik op 'Variabelen' -> Klik op 'Maak een variabele...' -> Geef uw variabele een naam (score) -> Druk 'OK' of Enter
Startscherm Maken
![opstarten2.PNG](/proxy/?url=https://content.instructables.com/FUC/4LUB/KUQYFAYU/FUC4LUBKUQYFAYU.png&filename=opstarten2.PNG)
Voor de startscherm te maken heb je een 'bij opstarten' blok nodig. Na dat je de blok hebt voeg een tekst of afbeelding naar uw keuze. Daarna voeg de variabele blok 'stel (score) in op 0 en verander 0 naar 2.
Spelers
![spelers3.PNG](/proxy/?url=https://content.instructables.com/FL6/MR7B/KUQYFDOS/FL6MR7BKUQYFDOS.png&filename=spelers3.PNG)
Voor de besturing van de Micro:bit spel hebben we twee knoppen nodig: A en B.
Voeg de invoer blokken 'wanneer knop A wordt ingedrukt' en 'wanneer knop B wordt ingedrukt'. Daarna voeg in beide blokken de variabele blok 'verander (score) met 1'.
Bij de knop A blok verander 1 naar -0.25. Bij de knop B blok verander 1 naar 0.25.
Functie Maken
![4functie.PNG](/proxy/?url=https://content.instructables.com/FX9/0WVK/KUQYFFV1/FX90WVKKUQYFFV1.png&filename=4functie.PNG)
![4functieals.PNG](/proxy/?url=https://content.instructables.com/FL7/2XY1/KUQYFHC9/FL72XY1KUQYFHC9.png&filename=4functieals.PNG)
De functie aanmaken is het belangerijkste stap in dit instructable. De functie blok gaat ervoor zorgen dat de spel werkt en kan worden gespeeld.
Open 'Geavanceerd' en maak een functie (paint) -> Voeg 'functie (paint)' blok -> Voeg 'wis scherm' ->Voeg de lichtjes blok ' teken x 0 y 0' en voeg de variabele (score) in x en verander y van 0 naar 2.
De blokken van onder zorgen voor de eindresultaat als A of B wint.
Neem de 2de foto in dit step en maak het na.
Functie Blokken Toevoegen
![hgfhgfh.PNG](/proxy/?url=https://content.instructables.com/FFY/B4W1/KUQYFITQ/FFYB4W1KUQYFITQ.png&filename=hgfhgfh.PNG)
![hklko.PNG](/proxy/?url=https://content.instructables.com/FAL/O8Z9/KUQYFITR/FALO8Z9KUQYFITR.png&filename=hklko.PNG)
Na dat je de functie blok afgewerkt heb voeg de functie blok 'aanroep (paint)' bij de blokken 'bij opstarten', 'wanneer knop A wordt ingedrukt' en 'wanneer knop B wordt ingedrukt' onderaan toevoegen.
En nu heb je uw eigen spel van "Tug-of-War" of "Touwtrekken" op een Micro:bit.