In this block, we just need to input a starting point and then plot it to screen. We use these throughout the program to keep track of the LEDs position. In the variables menu, we create two variables X-Pos and Y-Pos. The On Start Block: The above image shows how the LED matrix is arranged in terms of x and y and also where our starting LED is plotted. The contents of the variables are updated by user input and the results are plotted to the screen in real time. The code relies heavily on the use of variables, in this case, X-Pos and Y-Pos. There are five distinct chunks of code, four that handle each type of user input and one that sets the starting position for the LED. Additionally, there is code that ensures the lit LED can't disappear off the edge of the LED matrix. A moves the LED left, B moves the LED right, A+B moves the LED up and shake brings it to the bottom of the column. The lit LED is given a starting position and the user input takes over from there. The code accepts input from the user via the microbits A and B buttons and also when the microbit is shaken. Jumpġ - Take The Scenic Route: Disclaimer: Firstly, don't be put off by this method, there are easier and more efficient ones to follow! What does the code do: 4 - Using a dedicated gaming platform such as the :GAME Controller.3 - Use the 'Map block' to gather user input from a joystick via the microbit gpio pins.2 - Use the MakeCode 'Game blocks' to create a sprite on the screen, then move it with button presses.1 - Using the 'LED blocks' in the MakeCode editor to light up an LED, then move it with button presses.All of the examples are coded using the Microsoft MakeCode editor and we chose to use blocks. The first two make use of the Input buttons of the microbit, the third utilises an external analogue device and the fourth makes use of the :GAME Controller for BBC micro:bit. We've got four code examples to go through, starting with the most difficult/unwieldy first. Microbit Games - Controlling Movement On The LED Matrix: That there is always more than one way to get the desired result.Controlling movement on the LED matrix.How to process user input from an external device.Optional: An input device such as a thumbslide joystick, or thumb joystick.A computer/laptop with a USB port and internet access (or MakeCode Desktop App).We will illustrate three ways of processing user input and also three ways of moving an led around the matrix. Although we referred to Today's topics as basics, they can become quite tricky if your game is quite complex. Processing user input and also taking control of the LED matrix, both required knowledge if you want to create engaging games. Today we are going to take it back to basics and learn a couple of key concepts. Learning how to code some basic gaming functions could be all you need to overcome coders block. Do you have an urge to write some microbit games but don't know how to start, maybe we can help.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |