Time for action – building the draw-and-guess game
We will implement the game flow of the draw-and-guess game as follows:
- First, we will add the game logic on the client side.
- Open the
index.html
file in the client directory. Add the following restart button right after the send button:<input type="button" value="Restart" id="restart">
- Open the
html5games.websocket.js
JavaScript. - We need a few more constants to determine different states during the game play. Add the following highlighted code to the top of the file:
// Constants LINE_SEGMENT : 0, CHAT_MESSAGE : 1, GAME_LOGIC : 2, // Constant for game logic state WAITING_TO_START : 0, GAME_START : 1, GAME_OVER : 2, GAME_RESTART : 3,
- In addition, we want a flag to indicate this player is in charge of ...
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.