index.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <style type="text/css">
  2. html,body{
  3. margin: 0;
  4. padding: 0;
  5. font-family: Arial, sans-serif;
  6. }
  7. #game-container {
  8. width: 100%;
  9. height: 100%;
  10. z-index: 1;
  11. }
  12. #leaderboard {
  13. position: absolute;
  14. bottom: 0;
  15. left: 0;
  16. z-index: 10;
  17. padding: 10px;
  18. background-color: rgba(255, 255, 255, 0.5);
  19. }
  20. #eventticker {
  21. position: absolute;
  22. top: 0;
  23. width: 100%;
  24. z-index: 10;
  25. background-color: rgba(255, 255, 255, 0.5);
  26. overflow: hidden;
  27. display: block;
  28. }
  29. #eventticker p {
  30. display: inline;
  31. }
  32. p {
  33. margin: 0px;
  34. padding: 0px;
  35. }
  36. </style>
  37. <div id="game-container"></div>
  38. <script type="text/javascript" src="system.js"></script>
  39. <script type="text/javascript" src="keyboardinput.js"></script>
  40. <script type="text/javascript" src="player.js"></script>
  41. <script type="text/javascript" src="examplegame.js"></script>
  42. <script type="text/javascript">
  43. document.addEventListener("DOMContentLoaded", function(event) {
  44. window.WebSocket = window.WebSocket || window.MozWebSocket;
  45. //var socketString = "ws://" + window.location.hostname + ":" + window.location.port;
  46. var socketString = "ws://" + window.location.hostname + ":8080";
  47. var connection = new WebSocket(socketString);
  48. connection.onopen = function () {
  49. };
  50. connection.onerror = function (error) {
  51. console.error(error);
  52. };
  53. connection.onmessage = function (message) {
  54. try {
  55. var json = JSON.parse(message.data);
  56. system.handleServerMessage(json);
  57. } catch (e) {
  58. console.error("This doesn't look like a valid JSON ", message.data);
  59. console.error(e, e.stack);
  60. return;
  61. }
  62. };
  63. connection.onclose = function () {
  64. system.game.disconnect();
  65. };
  66. window.system = new System();
  67. system.create("game-container", new ExampleGame(connection), "#000000");
  68. });
  69. </script>
  70. <script>
  71. </script>