O'Reilly logo

HTML5 Game Development HOTSHOT by Makzan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making the sushi

In this task, we add the logic to composite the sushi by selecting the ingredients.

Prepare for lift off

The following figure shows the recipes of the sushi:

Prepare for lift off

Engage thrusters

Follow the given steps to create the sushi:

  1. We need a function to compare two given arrays. The array is in one dimension only so we don't need any deep comparison. Put the following comparing function in the helpers.js file:
    game.helper.arrayIsEqual = function(array1, array2) {
      if (array1.length !== array2.length) {
        return false;
      }
      for (var i = 0, len=array1.length; i < len; i++) {
        if (array1[i] !== array2[i]) {
          return false;
        }
      }
      return true;
    };
  2. Then we need another ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required