Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying HTML5 Game Development Hotshot
  • Table Of Contents Toc
HTML5 Game Development Hotshot

HTML5 Game Development Hotshot

By : Seng Hin Mak, Makzan Makzan (Mak Seng Hin)
4 (6)
close
close
HTML5 Game Development Hotshot

HTML5 Game Development Hotshot

4 (6)
By: Seng Hin Mak, Makzan Makzan (Mak Seng Hin)

Overview of this book

With a wide range of projects to build, this step-by-step guide will give you all the tools you need to create a variety of games. Whether you are familiar with the basics of object-oriented programming concepts, are new to HTML game development, or are familiar with just web design, this project-based book will get you up and running in no time. It will teach and inspire you to create great interactive content on the Web.
Table of Contents (10 chapters)
close
close
9
Index

Refilling sushi ingredients


In this task, we will control the ingredients' amounts and refill. We will also introduce a currency.

Engage thrusters

In these steps, we will polish the game with a cash mechanism:

  1. We store the cash value in the data.js file:

    game.cash = 1000;
  2. In the view.js file, we define a corresponding refresh method:

    var cashNode = document.getElementById('status-bar');
    game.view.refreshCash = function(){
      cashNode.textContent = '$' + game.cash;
    }
  3. We ensure that the cash DOM node shows the cash correctly by refreshing it when the game starts:

    game.view.refreshCash();
  4. In the data.js file, we define how many pieces of each ingredient need to be set up. Initially, the number is set to 10:

    game.amount = [];
    game.amount['rice'] = 10;
    game.amount['octopus'] = 10;
    game.amount['salmon'] = 10;
    game.amount['salmon-roe'] = 10;
    game.amount['seaweed'] = 10;
    game.amount['egg'] = 10;
  5. We add a method to increase the amount of total ingredients:

    game.increaseAmount = function() {
      for(var key in game...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
HTML5 Game Development Hotshot
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon