Time for action – making the Untangle puzzle game in Canvas
Let's add the game logic to our line intersection code:
- We need two more files for the game logic. Create two new files named
untangle.game.js
anduntangle.levels.js
file. Put them into thejs
folder. - Open the
index.html
file in a text editor. Add the following code to include our newly created file. Put the code in the file before including thejs/untangle.js
file:<script src="js/untangle.levels.js"></script> <script src="js/untangle.game.js"></script>
- Still in the
index.html
file, we add the following code after thecanvas
element. It displays the game level information:<p>Puzzle <span id="level">0</span>, Completeness: <span id="progress">0</span>%</p>
- Open the
untangle.levels.js
file. ...
Get HTML5 Game Development by Example : Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.