@opherv / Jul 2016
I work with developers, designers and video makers to create some pretty cool experiences
I'm a creative developer at Interlude
"Desktop and Mobile HTML5 Game Framework:
A fast, free and fun open source framework for Canvas and WebGL powered browser games"
Backend as a service
Realtime client updates / JS API
Commandos can move one square in any direction
When a commando touches another commando, he kills him and stops moving
A dead commando leaves his underwear in the square where he died
Commandos can't walk on squares with underwear
Desktop
Clients
Firebase
Game State is saved on desktop instance
Clients send their requests to firebase
Desktop consumes requests and updates game world
Desktop
Clients
Firebase
(for large scale projects)
It doesn't deal with:
...but it works! and it's cool!
and I only have 30 mins.
More work to be done:
var gameBoard = new Array();
for (var x=0; x< gridSize; x++){
gameBoard.push(new Array());
for (var y=0; y< gridSize; y++){
gameBoard[x][y] = "empty";
}
}
//moving a commando: checking the game state
function moveCommando(commando, x, y){
//hit game edge
if (x<0 || x>=gridSize || y<0 || y>=gridSize){ return; }
//hit an enemy
if (typeof gameBoard[x][y] == "object"){
killCommando(commando,gameBoard[x][y]);
return;
}
...
}
var playersRef = new Firebase('https://goingcommando.firebaseio.com/players');
var newPlayerRef = playersRef.push();
newPlayerRef.set({
color: playerColor,
id: newPlayerRef.key()
});
var playersRef = new Firebase('https://goingcommando.firebaseio.com/players');
playersRef.remove();
playersRef.on('child_added', function(snapshot) {
var newCommando = snapshot.val();
makeNewCommando(newCommando.id, newCommando.color);
});
function makeNewCommando(id, color){
var gridPosition = {
x: Math.floor(Math.random() * gridSize),
y: Math.floor(Math.random() * gridSize)
}
var commando = game.add.sprite(gridPosition.x * squareSize,
gridPosition.y * squareSize,
'commando');
commando.width = squareSize;
commando.height = squareSize;
commando.gridPosition = gridPosition;
commando.id = id;
gameBoard[gridPosition.x][gridPosition.y] = commando;
commando.color = color;
players[commando.id] = commando; //add commando to player array
};
It's a less ideal for low latency games:
physics, action, shooters
(Rocket League, World of Warcraft, Call of Duty)
Firebase is a good match for medium to high latency games:
turn based, discrete movement, strategy, puzzle
(Chess, Hearthstone, Clash of Clans)
@OpherV
opherv.com
github.com/opherv
none of your business