What is it
MekaCode is part of the ReachEDU app that I developed while working at Reach Robotics
It allows students to create more complex programs using Scratch-like block coding. MekaCode features all the tools necessary to create simple or complex programs for MekaMon.
- The app was built in Unity, using C#
- Bluetooth LE (BLE) is used to communicate with the MekaMon Robot
- Communication with MekaCentral, the RESTful web backend for MekaMon, created by the web team at Reach Robotics
- Offline local caching layer
- Based upon MIT's Scratch 3.0, and Google Blockly
What did I do
I did all the app-side development on this project, with the exception of the Missions system, an interactive series of lessons teaching the basics of Programming.
I had to work closely with the hardware & web teams at Reach Robotics, to implement new packets needed on the Robot, and for storing & implementing the social & sharing features on their custom backend.
UI graphic design & assets were done by Maff Evans
MekaCode is heavily based upon Scratch, and Blockly. The core code is a close port of scratch-blocks from Scratch 3.0 (Apache 2.0 Licensed). The execution system, block rendering and interaction are original, that I wrote to work efficently within Unity & run smoothly on weak hardware, including £100 android tablets.
Easy, simple to use interface, designed to be familiar to Scratch users, but also provide various improvements
Custom input system
Here's some of the interesting things I had to implement for this feature:
Block hierarchy system
- Implemented using an infinite scrolling, pooled horizontal list.
- The elements for each frame are instantiated at startup, cached, and recycled as you scroll.
- This ensures consistent, smooth performance even on low end mobile devices, with no sudden frame spikes that could affect animation playback
Block rendering system
- The solution had for block rendering had to meet a few requirements:
- Be atleast as versatile as Scratch's system
- Easily be styled by our UI artist, Maff
- Extremely performant, especially on low end (£100) android tablets, due to the cost limitations of the educational market
- Show execution through the program
- I came up with a solution using custom layout components, renderers and shaders ontop of Unity's UI system.
- All possible blocks shared the same texture, and an entire screens worth would batch into just a few draw calls (One for the block backgrounds, and up to two for text, due to two font weights being used)
The block rendering system is extremely flexible
The block rendering system was designed for very heavy batching - an entire screens worth of blocks will only be up to 12 draw calls
- To make interaction seamless, and to keep the program child friendly, I wanted to avoid ever having to open the native device keyboard.
- I designed a series of controls for different types of inputs, and tagged the inputs on different blocks to open the appropriate type.
- These included a keypad for entering numbers, sliders for entering numbers in a fixed range, an angle input and a colour input
- Designing the execution system within the limits of Unity was a challenge. I needed to be able to run multiple block chains at once, be able to create infinite loops without stalling unity, but also the majority of blocks are just sending BLE packets, which is not thread-safe in our app.
- My solution involved using IEnumerators similar to how they're used in Unity's coroutines, but using a custom system for iterating them to allow them to only run up to 16ms of frametime.
- The execution system is similar to a virtual processor, with it's own stack, "registers" (in this case, named parameters), and branching.
Browser, Storage & Sharing
- Storage, browsing & sharing of user content for MekaCode uses the same system that I wrote for MekaMotion (see part 2 on my writeup on MekaMotion here), but I adapted it to be a generic system for storing and interacting with user generated content. It stores content on both the local storage & remotely on MekaCentral, our RESTful web backend. It allows users to like, comment, share & remix other peoples content