Code'n'Play library.
Everything started with a crazy idea...
Wouldn´t be great to have a low-cost, easy-to-program , C/C++ , RPi based, handle videogame console?
Wow... Are you crazy? ...But, how about using Biicode, and its new RPi support? How about creating a RPi shield that will "support" the videogame console, and a library, that will include everything you need to program your videogames, in a new fashion way? Ok..
(there is also a contest, so, let's try that deadline as well)
(Yes, WE LOVE deadlines. Yes, WE LOVE lack of sleep following crazy ideas. And YES!, WE LOVE videogames)
Note: one great side-effect about this setup is that, using Biicode, we can program the same game to be 100% cross platform. It will run on a Desktop PC and on the RPi handle console, without minor or no code modification at all.
This is going to be long so, please, take your time...
Keep it simple, and dirty.
What do we need:
(To be bought from the same store, if possible)
So, here is our selected hardware:
Screen: Adafruit 3.5" TFT PAL/NTSC
Joystick: Sparkfun Joystick
Buttons: Square buttons
Battery: LiPo 1S 6000 mAh battery
Battery charger and regulators (5V for the RPi, 12V for the Screen):
One GPIO expander and one analog to digital converter, for the buttons and joystick.
One shield to play them all
Basic schema:
We received all the hardware:
First hardware mock-up:
Testing electronics:
And buttons board:
Ready for first (final) assembly:
Ready for first boot:
Flap, flap, little bee.
As we need a framework to work with, without the hardware, we configure a QEMU raspbian image with everything that we need for programming our first videogame, and Biicode library.
Did you like flappy bird? You will love Flappy Bee! Jump to get the same hive colors, without touching ground! (Ok, it was just a "proof of concept": be kind.)
The software scheme:
We are using SDL as the main graphic library. We tried to upload it to Biicode, without positive results. Finally, we decided to used it as one external dependency.
For the buttons and joystick handler, we are using the drogon/wiringPi library.
Physics using Eigen library, also in Biicode.
Genius at work: Please, hold the line.
The basic idea:
Code'n'Play will include high level classes to handle not only IO interfaces with the console, but will wrap an easy-to-use framework, higher than the SDL, to program videogames, using Biicode.
Example classes:
Link to Biicode library block and example.
Always inside a nice envelope (as far as you can...)
We design a holding structure and case prototype for the shield. The idea was a Plug-and-Play system, where the player/developer only needs to build/buy/obtain the Code'n'Play shield, he would install a custom-made Raspian image, with a Menu to load the games and, using his own Raspberry, will be ready to roll.
We modeled the electronics using a CAD program, and designed the case and structured around it. A video of the assembly and how to used it, after the break.
We used a Reprap Prusa Mendel printer to print all the parts.
Where the problems begin...
Bii uses a cross-compiler in order generate the binary file, that will be load into the RPi.
Our library will used other Biicode libraries, like WiringPi or Eigen, which are already there. But, we want to use SDL as our main videogame and media manager library, which is not.
First step: install SDL locally in our RPi, and compile example code. This works fine.
Second step: using bii to generate executables using wiring pi, to control buttons and joysticks, sending it to the RPi via ssh. This also works.
So, what's next? Let's try to, using the pre-compiled SDL from the RPi, compile our videogame using and configuring the cross compilers.
After spending almost a week working on this, we are still working, and the cross compiler cannot locate the pre-compiled SDL...
The end?
Although we think this console-shield can have a lot of potential, trying to combine the SDL with our library was a big mess.
Trying to compile the code, modifying the biicode's CMAKE files seems the way-to-go. At this moment, headers files are located but it doesn't link the final solution. Some of the libraries are located, but others are not. Also, passing SDL configuration options to the cross compiler looks difficult, or not working.
So, here you are the conclusions:
Next steps:
Finally, Biicode contest was a great way to made us learn the tool, and it push us forward to finish our prototype, so, thank you! :)