how did we do our foosball match smarter

Monday, 08 June 2015 10:11

Hello everyone!

We would like to share the experience of a non standard development, which we recently cranked.

As in any IT office during lunch breaks people are engaged in something completely outside of the workflow. The most popular here is a table football, which is sometimes hard to get through.

That's how we decided to alleviate the "footballers" life, and ourselves too. Who has played, he can understand that it is extremely difficult to pick an adequate mate or match, finally, to wait for their turn. We would like to add a little more interesting features, such as receiving of achievements or conducting the raitings of the players.

Therefore, assembling a team of 5 developers, we started the experiment.

Now more details about the process of the development.

The first step, when we began the idea implementation was the upgrading of the football table. Its idea is very simple: each goal scored should be tracked. The project implementation was accelerated with 2 lasers and 2 photoresistors fixed in the goal, the Arduino controller and, of course, the enthusiasm of our members.

How does it work?

When the ball gets into the area between the laser and the photoresistor it changes the resistance of the photoresistor, which changes the voltage fixed by the Arduino controller. Schematic diagram is shown below:

The simplicity of the system does not eliminate the problems. Firstly, in the room with the football table the lighting constantly changes (day/electric light). These interruptions cause false-positive responses of the sensors. Secondly, all the components are to be firmly fixed because the vibration at the game could damage it.

The first problem we eliminated with the recalibration of the photoresistor at each start of the game.

The second discrepancy was resolved easier - with superglue, blue tape and a screwdriver. Therefore, within half an hour all the components of the table were properly fixed and ready for further actions.

Our team of the volunteers started to “polish” the requirements for the software component of the project. The collective brainstorming generated a number of ideas. The most interesting are:

  • Game mode can be represented as 1x1 and 2x2.
  • Distribution of the levels of the players.
  • Obtain of the achievements during and at the end of the game.
  • Suport of the individual and team rates.
  • Sound accompaniment of the game.

Hereafter the developers began on the design of the project, from the logo to the fine details of the application. Here's what happened.

The development of the project software component was divided into three stages:

  • Client Side - Angular.js, Bootstrap.

The implementation of the client side, we carried out as follows:

  • We developed the main pages of the application and applied the design on them.
  • Implemented the communication with the server via the Rest API and Socket.io.
  • Server Side - Node.js, Socket.io, MongoDB.

The server side was developing like this:

  • We generated the project structure.
  • Developed a data model.
  • Established the connection between the client and the server.
  • Implemented the logic of the statistics settlement.
  • Implemented the logic of the achievements obtain.
  • The connection between the Arduino and the server.
  • We wrote the layer between the Arduino and the server, which helped to collect all project parts together.

On the side of the Arduino:

https://gist.github.com/anonymous/fb7a63367e7a722dc272

On the server side the folliwing controller was implemented:

https://gist.github.com/anonymous/b6a382e4b385a79c0a7b

The principle of the operation was as follows: we should listen to the port connected with the Arduino, and when the command was received we emited an event. To start and stop the Arduino, we had two special functions “start” and “stop”. When the functions were running, the corresponding command should be sent into the port for the processing by the Arduino.

In the game controller we catch the event and perform the magic known only for the developers. Example of usage:

https://gist.github.com/anonymous/4fb2ca45ffb02f2509b5
  • Furthermore, the game controller emits different events: the start of the game, the end of the game, obtain of the achievements.
  • Then we continued the upgrade of the table.
  • Vital were only two tasks: to finish the programming part of the project and connect all system components together.

We implemented:

  • counting of the statistics,
  • counting and obtain of the achievements by the player,
  • storage of the statistics and achievements in the database,
  • design for all achievements.

And now it is a long-awaited moment, the last line of code has been finished, the last screw has been screwed, we can start the game.

The outcome:

As a result, we have the prototype of the tech table football, which can register and count the goals scored, manage the top players on the remote computer.

We hope that it was not our last experiment and we will continue to surprise you, and ourself.

Good luck!

100.000 visitors per second? the story behind a startup in the cave of lions More