diff --git a/source/main.cpp b/source/main.cpp index d61165f8b7d982c4232156e68597a06f6fce6d9c..42d8caaa8ff2b1b6b3c64328d50d8f7f3134fbda 100755 --- a/source/main.cpp +++ b/source/main.cpp @@ -17,16 +17,41 @@ #include "MicroBit.h" -MicroBit uBit; -int main() -{ +class Game { +public: + Game(MicroBit& micro_bit); + + void run(); + +private: + MicroBit& micro_bit; +}; + +Game::Game(MicroBit& micro_bit) + : micro_bit(micro_bit) + {} + +void Game::run() { + this->micro_bit.display.scroll("NEW GAME"); +} + +MicroBit micro_bit; + +int main(void) { // Initialise the micro:bit runtime. - uBit.init(); + micro_bit.init(); + + // startup message displays the name of the game + micro_bit.display.scroll("BLOCKS!"); - // Insert your code here! - uBit.display.scroll("HELLO WORLD! :)"); + // infinitely start new games + while (true) { + Game game(micro_bit); + game.run(); + } + // TODO: potentially remove this call, if clarified that it is not required. // If main exits, there may still be other fibers running or registered event handlers etc. // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then // sit in the idle task forever, in a power efficient sleep.