HTML and CSS Reference
In-Depth Information
Figure 5-9. Player 1 moves
After the second player makes a selection, the results are displayed immediately to
both players, as shown in Figure 5-10 .
Figure 5-10. Player 2 moves
In a “real” rock-paper-scissors game, after each round you want to declare a winner.
For the sake of keeping this demo simple and the source code focused, we do not include
this feature.
Creating the Game
Our simple application consists of our own HTML and a JavaScript file, and leverages two
external open source JavaScript resources. The first JavaScript library is called stomp.js ,
and was written by Jeff Mesnil. This library is included in the distribution for this topic,
but can also be found on GitHub: https://github.com/jmesnil/stomp-websocket . This
library enables a JavaScript application to speak STOMP/WS with our WebSocket-enabled
ActiveMQ message broker.
The second JavaScript library is jQuery, which we use for simplicity and helps
us write our code in a more concise manner. We call our HTML and JavaScript files
containing our application logic index.html and rps.js , respectively.
 
Search WWH ::




Custom Search