Skip to content
Snippets Groups Projects
Select Git revision
  • main default protected
  • dev
  • minh
  • trung
4 results

app

  • Clone with SSH
  • Clone with HTTPS
  • UFCFVK-15-2 - Internet of things - Challenge 1

    Blocks

    A clone of a well-known computer game, written in C++ for the BBC micro:bit

    Shift and rotate the descending shapes to stack them up and try to line the blocks up in a row to stop the stack reaching the top of the screen!

    Build Instructions

    These instructions are intended for UNIX-like OSes, including GNU/Linux, macOS and friends. If you have access to a UNIX or POSIX environment on Windows such as MinGW or Cygwin, these instructions might also work there.

    This project is written in C++ and uses the Device Abstraction Layer provided by Lancaster University.

    You will need git to download the project code and yotta to build it.

    Instructions for installing both of these and other prerequisites needed for building this project can be found here.

    Once the prerequisites have been installed, in the root directory of the repo, run the following:

    # set the compiler target architecture (only need to do once per shell session)
    yt target bbc-microbit-classic-gcc
    # this compiles the actual code
    yt build

    Be patient during compilation, if this is the first time you have cloned the source code, first-time compilation may take a while.

    When compilation has completed successfully, the executable file which is to be flashed onto the micro:bit can be found at build/bbc-microbit-classic-gcc/source/ufcfvk-15-2-internet-of-things-challenge-1-combined.hex

    This needs to be flashed onto the micro:bit. This can be done by copying the executable file onto the removable drive that the micro:bit exposes when connected by USB to a computer, for example:

    # NOTE: this assumes that your micro:bit is mounted at "/media/sf_MICROBIT/"
    #       it's probably actually located somewhere else on your machine
    cp build/bbc-microbit-classic-gcc/source/ufcfvk-15-2-internet-of-things-challenge-1-combined.hex /media/sf_MICROBIT/

    The micro:bit will flash its LED when it is being flashed. If successful, the LED should turn solid and the game should start running.

    Blocks very quickly draws three dots to the screen, then scrolls the text BLOCKS! on startup. The game then begins immediately.

    How to Play

    Blocks descend from the top to the bottom of the screen, one by one.

    Blocks stack up gradually until there is no space left on the screen. The game is over when there is not enough space for the next block.

    The aim of the game is to prevent this from happening for as long as possible by careful arrangement of the blocks as they descend, shifting and rotating them as required.

    If any row of the screen is completely filled end-to-end with blocks, then this row is erased and all blocks above them descend downwards. Bonus points are awarded when this happens.

    Points are also awarded for every block that is stacked successfully.

    Controls

    • Shift the current block left or right by tilting the micro:bit left or right.
    • Rotate the block anti-clockwise by pressing button A, or rotate it clockwise by pressing button B.

    When game over occurs, the player's score is displayed.

    The game then starts again immediately.

    Coding Convention

    This project follows the PEP 8 Style Guide for Python Code, at least as much as a style guide for Python can be followed when writing C++, which is actually quite a bit!

    License

    Licensed under the Mozilla Public License v2.0 (MPL-2.0).