HTML and CSS Reference
In-Depth Information
6. A customer isn't displayed immediately when he or she is created. We only display
the irst customer in the queue. Therefore, the game ick funcion in the game.js
file will display the customer in front of the sushi stand. We define the following
method to display the customer:
Customer.prototype.showUp = function() { = new lib['Customer'+this.number]();'normal'); // normal state at first'click', customerOnClick.bind(this));
// bubble that shows what sushi the customer wants.
var bubble = new lib.Bubble();
bubble.x = -40;
bubble.y = -120;
// set the type
this.hasShownUp = true; // mark the flag
7. Make sure to export the Customer deiniion to the game scope for other logic to
access it:
game.Customer = Customer;
8. When a customer is clicked on, we send the sushi in hand to the customer. If the
sushi in hand matches the sushi request, the customer leaves happily:
function customerOnClick() {
// check if is what customer wants
var isEqual =
if (isEqual) {
this.hasEaten = true;
9. Let's move to queue management. We define two arrays to store customer queues:
game.queues = [];
game.queues[0] = [];
game.queues[1] = [];
Search WWH ::

Custom Search