Grasshopper / Rhino3D

Grasshopper game: DragRace with Firebase

When teaching Grasshopper, it is sometimes nice to take a slightly different approach. For example in the form of a game. DragRace is about uploading scores to an online database and trying to win with the fastest score!

The concept of live data exchange via the web, in combination with geometric applications such as in Rhino, offers many possibilities.

DragRace is a simple test with the plugin FireHopper. The plugin has not been in development for some time but is still relevant and working with the current API of Firebase, a (to some extent) free database system from Google.

Through the API calls that are possible from grasshopper thanks to the FireHopper plugin, live data can be exchanged in the JSON format.

This part is included in the script that can be downloaded at the bottom of this page. You can of course place your own API in this part of the script in the blank slate version at the bottom.

In the Firebase database the date can then be read out as follows:

The DragRace game

In this video Friso explains a few things about this setup:

A game contains some important elements:

  • A clear goal
  • Different levels of difficulty
  • A competition element

All these parts are built in the script as a way of exercise.

  • It is possible to choose the number of points to be gained and to set your name. (Step 2 in the picture below)
  • The goal is to score the points as quickly as possible by dragging the slider back and forth. Hence DragRace as a name.(Step 3)
  • As soon as the value is obtained it will be stored in the database in firebase.
  • Finally you can see the score of yourself and others in the database. That is competition element. (Step 4)
At the top left you can reset the game by clicking on the X for a new chance.

Proof of concept

Of course, the game is not accessible to the average user, but should be seen as an exercise in exchanging data over the Internet between different players. In a larger project, for example, this can be the exchange of geometric data.

Download and play!

Download the script here to try out how it works for yourself.

Here is a version without api and database data to add your own database.