Using WebRTC peer-to-peer data channels.
The buttonPressed function is used in the update loop of the game like this:
In the end the newPress variable is returned. If we find it there it means that the button is being held, so there's no new press. To check if the press is a new one, so the player is not holding the key, we loop through the cached states of the buttons from the previous frame of the game loop. Next, we loop through the array of pressed buttons - if the given button is the same as the one we're looking for, the newPress variable is set to true. The newPress boolean variable will indicate whether there's a new press of a button or not.
There are two types of action to consider for a button: a single press and a hold. The game encapsulates two totally different types of "change" - good food vs. You have to shoot down the food, but once again you also have to find the type of food the Fridge wants to eat at each point, or else you'll lose energy. When you connect the controller, the game significantly changes (Hungry Fridge turns into the Super Turbo Hungry Fridge) and you're able to control the armored fridge using the Gamepad API. The second, hidden "change" implementation is the ability to transform the static Fridge into a full-blown moving, shooting and eating machine. The theme for the competition was "change", so they submitted a game where you have to feed the Hungry Fridge by tapping the healthy food (apples, carrots, lettuces) and avoid the "bad" food (beer, burgers, pizza.) A countdown changes the type of food the Fridge wants to eat every few seconds, so you have to be careful and act quickly. The GitHub Game Off II competition ran in November 2013 and Enclave Games decided to take part in it.