Arithmetic Artillery
COMP 50H Final Project by Tom Nguyen
Overview
Arithmetic Artillery is a battleship game that requires you to create mathematical equations and solve equations created by the enemy player to land shots on the enemy ship.
How it Works
How it Works
Database
In order for the game to be played between two players across the web, a database is used to facilitate the exchange of data between the players. For that purpose, I used Google’s Firebase real time database service.
Asynchronous Communication
//Player 1 is defined
var player1 = { name: “” };
//Player 1 is given a name
player1.name = “Steve”;
//Calling for Player 1’s name
alert(player1.name);
//Result: “Steve”
//Player 1 is defined
var player1 = { name: “” };
//Player 1’s name is read from database
return database.ref("player1/name”).once('value').then(function(snapshot){
player1.name = snapshot.val();
});
//Calling for Player 1’s name
alert(player1.name);
//Result could be “Steve” or “” as there is no guarantee that the name has been retrieved by the time alert() executes.
Why I Chose This Project