Time for action – placing Ping Pong game elements in the DOM
- We will continue from our jQuery installation example, and open the
index.html
file in a text editor. - Then, we will create the following playground and
game
objects with DIV nodes in the body. There are two paddles and one ball inside the playground, and the playground is placed inside the game:<div id="game"> <div id="playground"> <div class="paddle-hand right"></div> <div class="paddle-hand left"></div> <div id="paddleA" class="paddle"></div> <div id="paddleB" class="paddle"></div> <div id="ball"></div> </div> </div>
- We now have the structure of the
game
object ready, and it is time to apply styles to them. We will add the following styles to thepingpong.css
file:#game { position: relative; ...
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.