Win destination. Shadows. Icons.

master
Ben Burlingham 5 years ago
parent 51d4f0e44e
commit 33fb7a897e
  1. 13
      README.txt
  2. 1
      assets/comet.svg
  3. 1
      assets/moon.svg
  4. 1
      assets/planet.svg
  5. 1
      assets/rocket.svg
  6. 1
      assets/spacesuit.svg
  7. 1
      assets/spider.svg
  8. 1
      assets/ufo.svg
  9. 1
      client/connection.js
  10. 65
      client/controls.js
  11. 146
      client/grid.js
  12. 39
      client/icons.js
  13. 6
      client/stack.js
  14. 14
      grid.css
  15. 3
      index.html
  16. 3
      package.json
  17. 3
      server.js
  18. 36
      server/game.js
  19. BIN
      sprite-robots.png

@ -9,22 +9,19 @@ Any movement, including initial locations, is represented by pushing or popping
A victory state can be stored by taking a snapshot of the current stack.
## TODO
- robot shadow starting spot
- robot icons with personality add credit to readmee
- countdown skip
- restore state on join
## Icons
Icons from [https://game-icons.net](https://game-icons.net)
## TODO
- win declare/add/remove
- goal
- no more guesses, send stack and replay
- countdown skip
- move guess and move logic out of server (clean up server file)
- no cancel from name prompt
- window resize update board
- restore state on join
- walls algorigthm
- restore state on join
- limit concurrent players, make sure connections are closed, clean up empty rooms
- cookie room link, add to all messages, namespace them

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;" id='foo'><g class="fill" transform="translate(0,0)" style="touch-action: none;"><path d="M20.916 15.648c147.945 202 202.556 312.645-3.146 252.438 201.76 82.926 225.515 176.51 49.13 180.76 190.922 51.156 315.057 60.258 377.16 10.43 67.76-54.368 62.6-177.648 13.31-361.6-.002 179.943-88.34 149.935-171.18-39.96 60.246 191.39-81.408 116.353-265.274-42.068zM457.37 97.676v-.008.008zm-79.792 150.84c5.457.054 10.994.79 16.508 2.267 3.763 1.01 7.352 2.34 10.77 3.924-.053-.058-.102-.12-.155-.178 51.248 21.08 79.986 77.264 65.253 132.25-16.008 59.742-77.174 95.054-136.914 79.046-59.29-15.886-94.507-76.24-79.395-135.547 1.144 7.843 3.71 15.465 7.808 22.564 15.038 26.045 46.48 37.745 78.735 32.334 8.387-.382 17.33-2.932 25.75-7.793 22.18-12.807 32.317-36.774 22.642-53.53-9.676-16.76-35.5-19.966-57.682-7.16-7.3 4.214-13.283 9.64-17.697 15.618-3.05-11-3.31-22.928-.14-34.75 7.978-29.778 35.053-49.34 64.518-49.047z" fill="#fff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;"><g class="" transform="translate(0,0)" style="touch-action: none;"><path d="M253.125 18.563c-131.53 0-238.375 106.813-238.375 238.343 0 131.53 106.846 238.344 238.375 238.344 131.53 0 238.344-106.815 238.344-238.344 0-131.528-106.816-238.344-238.345-238.344zm-23.938 52.093c40.517 0 77.988 12.904 108.532 34.813-5.597-.624-11.302-.97-17.064-.97-84.157 0-152.375 68.25-152.375 152.406 0 84.157 68.22 152.375 152.376 152.375 5.762 0 11.467-.313 17.063-.936-30.545 21.91-68.016 34.812-108.533 34.812-102.98 0-186.28-83.272-186.28-186.25 0-102.977 83.3-186.25 186.28-186.25z" fill="#fff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 717 B

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;"><g class="" transform="translate(0,0)" style="touch-action: none;"><path d="M417.063 85.625c-35.503-.147-80.717 9.822-129.563 28.97-9.31-1.8-18.804-2.706-28.344-2.69-25.04.045-50.414 6.454-73.656 19.907-32.044 18.55-54.554 47.287-65.813 79.782-80.284 64.16-123.395 133.9-100.718 173.28 23.35 40.55 109.384 36.656 208.593-4.218 1.7-.7 3.417-1.403 5.125-2.125.622-.262 1.25-.514 1.875-.78 1.81-.765 3.62-1.554 5.437-2.344l1.563-.687c1.443-.633 2.895-1.29 4.343-1.94 19.712-8.812 39.79-19.016 59.844-30.624 15.83-9.162 30.907-18.77 45.156-28.656.394-.273.795-.54 1.188-.813.672-.465 1.33-.94 2-1.406 100.373-70.007 158.15-152.83 132.625-197.155-11.013-19.123-35.953-28.36-69.658-28.5zm-56.375 50c24.466-.44 42.61 5.846 50.437 19.438 8.373 14.54 3.594 35.145-11.22 57.937-3.086-9.146-7.093-18.13-12.092-26.813-11.72-20.35-27.54-36.846-45.782-49.093 6.543-.87 12.788-1.364 18.658-1.47zM111.75 269.905c1.397 22.12 7.76 44.257 19.563 64.75 5.088 8.838 10.948 16.957 17.437 24.314-27.663 1.7-48.293-4.418-56.78-19.158-9.82-17.05-1.558-42.433 19.78-69.906zm291.22 27.658c-25.755 21.322-55.33 41.912-87.876 60.75-31.97 18.504-63.966 33.663-94.75 45.28 36.843 10.142 77.578 6.073 113.28-14.593 35.833-20.74 59.75-54.215 69.345-91.438z" fill="#fff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;"><g class="" transform="translate(0,0)" style="touch-action: none;"><path d="m 44.980642,443.8306 c 22.7502,-2.34 43.848,-8.3844 62.774998,-17.5788 l -5.9076,19.0962 51.8076,-50.7924 -1.6038,0.7587 c 15.561,-15.0633 28.242,-33.1173 37.4337,-53.4942 -16.9605,12.1914 -37.50929,19.4373 -62.35199,19.827 0.315,-25.002 7.704,-45.3564 19.85669,-62.325 -1.26,0.5643 -2.4984,1.1556 -3.7413,1.746 l 0.5625,-0.648 -77.989498,30.9942 30.4596,2.277 c -28.4382,27.8766 -46.8756,65.7396 -51.3,110.1384 z m 28.4337,-213.1326 92.980798,34.5366 c 6.768,27.5967 29.0124,49.1094 57.0096,54.8163 l -0.198,0.1692 35.60671,95.9067 66.8808,-66.8817 -7.227,-83.7 -0.0297,-0.3375 -2.2212,-20.727 -85.4442,69.579 -11.952,-11.952 c 38.55508,-35.39087 62.95377,-59.69364 108.74062,-106.82077 l 3.73058,31.97947 2.72699,25.398 C 420.52058,162.41503 431.5622,106.67889 437.08233,42.260533 327.6673,57.060205 303.80583,94.318657 235.47015,155.3788 l 23.51249,2.502 26.45775,3.73058 C 255.81465,198.02423 215.0597,232.2978 185.38064,268.6672 l -11.925,-11.925 68.31451,-83.7846 -18.7596,-1.998 -82.7424,-7.1145 -66.852008,66.852 z" fill="#fff" fill-opacity="1" /></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;"><g class="" transform="translate(0,0)" style="touch-action: none;"><path d="M250.375 21.25c-38.192 0-68.97 30.744-68.97 68.938 0 38.193 30.778 68.968 68.97 68.968s68.938-30.775 68.938-68.97c0-38.192-30.746-68.936-68.938-68.936zm-2.625 33.78c.115-.003.23.005.344 0-26.85 53.803 52.427 66.62 40.656 9.032 4.272 1.793 8.76 3.838 13.53 6.157 3.816 15.258 3.55 30.828-2.342 46.093-46.683 11.007-54.054 11.028-98.375-1.594-5.345-14.747-6.03-29.762-2.344-44.5 19.356-9.562 34.072-14.612 48.53-15.19zM345.188 121c-1.26-.03-4.597.75-9.657 4.625-.006.006-.022-.006-.03 0-2.61 2.002-5.202 3.89-7.78 5.688-14.765 27.642-43.906 46.53-77.345 46.53-33.4 0-62.523-18.846-77.313-46.437-3.012-1.64-6.038-3.325-9.093-5.062-4.647-2.642-7.37-2.825-8.657-2.594-1.29.23-2.174.692-3.657 3-2.966 4.616-5.316 16.393-4.656 30.03.66 13.64 3.802 29.176 8.75 42.314 4.948 13.138 11.957 23.675 18.156 27.97 50.81 35.192 99.385 27.478 151.5-.533 6.386-3.43 13.912-13.767 19.125-27.468 5.215-13.7 8.4-30.338 8.94-44.843.538-14.506-2.292-26.98-5.22-31.095-1.464-2.058-1.8-2.096-3.063-2.125zM128.25 144.875c-20.632 9.24-36.958 25.827-49.656 48.594 4.41.183 8.78.842 13 1.968 12.22 3.26 22.512 10.243 30.062 19.375 4.587-5.04 9.565-9.652 14.938-13.844-4.718-13.954-7.597-29.14-8.28-43.282-.214-4.392-.26-8.68-.064-12.813zm242.72 24.25c-1.58 12.405-4.592 25.058-8.97 36.563-2.413 6.342-5.193 12.393-8.5 17.843 3.59 4.06 6.944 8.37 10.03 12.97 2.334-3.646 5.037-7.03 8.064-10.063v-.03c8.18-8.18 18.247-13.41 28.844-15.75-8.07-16.84-17.822-30.79-29.47-41.532zM76.31 212.155c-10.683.044-21.528 4.17-28.312 12.282-7.128 8.523-11.038 22.262-5.188 43.375.136-.093.27-.19.407-.28 8.11-5.473 18.242-8.57 29.186-8.063 3.648.168 7.398.733 11.188 1.75 10.622 2.845 19.157 8.536 25.28 15.717 7.454-9.93 9.21-20.875 7.314-31.156-2.767-14.987-13.905-28.145-29.407-32.28-3.373-.9-6.906-1.358-10.468-1.344zm336.5 15.782c-.71.013-1.413.045-2.125.094-9.48.653-18.78 4.502-25.875 11.595-9.865 9.887-14.718 25.822-9.875 39.063 3.82 10.44 13.742 20.698 34.97 26.187-.015-.177-.05-.354-.063-.53-.91-13.01 3.634-26.97 14.72-38.064l-.002-.03c7.774-7.767 16.973-12.288 26.25-14-4.87-11.43-13.457-18.44-23.312-21.938-4.712-1.67-9.704-2.465-14.688-2.375zm-101.437 25.97c-39.896 16.718-81.177 21.096-121.78 3.312l-10.064 39.31c8.908 2.755 16.417 7.827 22 14.25 7.355 8.462 11.61 18.985 12.876 29.814 25.23-39.572 70.19-24.214 81.906 29.187-30.148 24.312-31.025 78.51 2.47 99.97 13.98-17.626 34.203-29.69 55.312-32.75 3.026-.44 6.09-.66 9.156-.688 1.022-.008 2.042-.006 3.063.032 7.237.266 14.457 1.735 21.312 4.562 5.298-16.073 4.073-34.643-3.188-50.156-7.642 4.648-17.087 7.406-27.843 7.406-16.64 0-30.15-6.565-38.688-16.594C309.37 371.534 305.66 358.6 306 345.938c.34-12.662 4.69-25.31 13.25-35.156 1.444-1.66 3.026-3.222 4.72-4.686l-12.595-52.188zm146.938 16.218c-7.058.166-13.97 2.75-20.563 9.344-7.534 7.533-9.85 15.483-9.28 23.592.566 8.11 4.486 16.41 10.436 22.688 5.95 6.28 13.738 10.374 21.53 11 7.795.626 15.888-1.73 24.377-10.22 8.488-8.488 10.845-16.58 10.218-24.374-.625-7.793-4.72-15.58-11-21.53-6.278-5.95-14.577-9.87-22.686-10.438-1.014-.07-2.023-.087-3.03-.063zM70.156 278c-6.352-.102-11.73 1.835-16.47 5.03-6.738 4.547-11.973 12.083-14.436 20.376-2.463 8.293-2.136 17.063 1.22 24.125 3.353 7.064 9.465 12.925 21.06 16.033 11.597 3.107 19.784 1.064 26.22-3.375 6.436-4.44 11.112-11.868 13.125-20.282 2.013-8.413 1.25-17.568-2.313-24.875-3.563-7.305-9.52-12.99-19.812-15.75-2.573-.688-5.007-1.084-7.313-1.217-.432-.025-.857-.056-1.28-.063zm94.03 34.938c-10.654 0-17.916 3.958-23.25 10.093-5.33 6.137-8.422 14.76-8.655 23.408-.232 8.647 2.37 17.046 7.44 23 5.067 5.953 12.462 10.03 24.468 10.03 12.005 0 19.4-4.077 24.468-10.03 5.068-5.954 7.67-14.353 7.438-23-.233-8.648-3.355-17.27-8.688-23.407-5.333-6.134-12.563-10.092-23.22-10.092zm192.408 0c-10.656 0-17.917 3.958-23.25 10.093-5.333 6.137-8.424 14.76-8.656 23.408-.233 8.647 2.37 17.046 7.437 23 5.068 5.953 12.463 10.03 24.47 10.03 12.004 0 19.4-4.077 24.467-10.03 5.07-5.954 7.67-14.353 7.438-23-.233-8.648-3.355-17.27-8.688-23.407-5.332-6.134-12.563-10.092-23.218-10.092zM121.22 375.656c-15.115 16.632-20.037 41.93-13.75 63.313 5.18-1.573 10.525-2.43 15.874-2.626 1.02-.038 2.04-.04 3.062-.03 3.065.025 6.13.247 9.156.686 22.062 3.2 43.178 16.216 57.188 35.156 34.58-17.894 37.7-67.857 13.75-95.5-1.098 1.69-2.296 3.345-3.625 4.906-8.537 10.03-22.048 16.594-38.688 16.594-16.64 0-30.15-6.565-38.687-16.594-1.59-1.87-3.02-3.855-4.28-5.906zm2.81 79.313c-8.685.26-16.853 2.96-24.124 8.592-7.895 6.116-14.975 16.094-19.72 31.344h104.25c-10.196-20.804-31.273-36.464-51.56-39.406-2.995-.434-5.95-.618-8.845-.53zm239.407 0c-2.192.034-4.41.204-6.656.53-20.287 2.942-41.364 18.602-51.56 39.406h104.25c-4.745-15.25-11.824-25.228-19.72-31.344-7.27-5.63-15.44-8.333-24.125-8.593-.724-.023-1.457-.013-2.188 0z" fill="#fff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;"><g class="" transform="translate(0,0)" style="touch-action: none;"><path d="M370.06 77.686c-10.644.085-21.42 1.936-31.816 5.86-14.63 5.53-17.103 17.274-12.506 23.895 14.11 29.535 18.452 62.364 3.78 90.1-17.168-25.923-43.89-42.415-73.518-42.415-29.626 0-56.347 16.496-73.516 42.42-14.672-27.734-10.335-60.56 3.772-90.09 4.606-6.62 2.138-18.37-12.5-23.894-41.58-15.69-89.25 1.756-110.16 32.82 30.66-8.7 66.99-27.915 103.05-7.155.675.39 1.342.735 1.997 1.045-13.33 33.103-15.584 70.885 5.423 102.39-3.543 7.674-6.336 15.914-8.263 24.588-26.844-17.095-39.352-48.493-41.52-81.71l-.17.01c-.018-8.626-13.526-18.352-30.46-12.02C52.03 159.1 27.61 203.606 32.32 240.76c17.003-26.187 38.658-65.485 77.91-74.688 4.368 35.197 20.396 69.337 53.086 87.086-.373 4.018-.572 8.1-.572 12.246 0 2.983.097 5.85.283 8.614-25.055-5.735-46.175-23.645-61.806-46.41-.038-.06-.084-.12-.124-.18-.353-.516-.72-1.02-1.067-1.54l-.08.05c-5.773-6.48-18.946-7.902-28.93 4.216-28.26 34.29-25.08 73.666-13.86 107.116 1.65-31.567 8.098-64.37 38.725-91.67 17.705 22.113 41.41 39.493 69.43 44.134 2.336 9.984 6.2 18.202 11.322 25.02-21.07 2.364-43.31-3.103-63.85-13.248l-.03.064c-7.296-3.463-17.49.828-19.402 16.125-5.475 43.83 14.19 87.256 39.99 101.73-13.334-23.954-23.805-58.905-13.8-98.31.023-.09.035-.177.057-.267 22.498 8.685 47.02 12.214 70.2 6.79 4.84 3.53 10.313 6.46 16.288 8.858-9.288 2.466-18.875 12.258-19.66 26.29-1.815 32.91 28.185 46.034 51.105 39.704-18.345-8.55-27.09-37.8-13.695-52.14-.348-3.926-1.426-6.985-3.006-9.262C231.57 343.6 243.418 344.8 256 344.8c13.92 0 26.943-1.463 38.55-4.556-1.927 2.343-3.25 5.674-3.646 10.106 13.395 14.34 4.652 43.59-13.693 52.14 22.92 6.33 52.92-6.795 51.104-39.705-.827-14.944-11.646-25.085-21.457-26.68 5.61-2.327 10.77-5.13 15.358-8.474 23.173 5.414 47.688 1.882 70.18-6.802.023.097.035.19.06.287 9.99 39.405-.466 74.34-13.8 98.31 25.8-14.46 45.465-57.885 39.99-101.73-1.912-15.3-12.11-19.59-19.405-16.123l-.04-.082c-20.533 10.14-42.762 15.61-63.825 13.252 5.114-6.814 8.976-15.025 11.31-25.002 28.02-4.637 51.726-22.026 69.43-44.14 30.627 27.3 37.074 60.104 38.725 91.656 11.22-33.45 14.4-72.81-13.86-107.115-9.984-12.11-23.157-10.683-28.93-4.2l-.08-.053c-.347.52-.713 1.025-1.066 1.54-.04.062-.086.12-.125.182-15.633 22.765-36.754 40.682-61.81 46.413.188-2.765.286-5.634.286-8.62 0-4.146-.2-8.233-.572-12.253 32.683-17.75 48.722-51.882 53.08-87.09 39.246 9.22 60.9 48.513 77.9 74.684 4.71-37.155-19.71-81.658-61.334-97.228-16.928-6.326-30.434 3.41-30.447 12.035l-.182-.01c-2.153 33.22-14.666 64.602-41.503 81.698-1.926-8.672-4.72-16.91-8.26-24.582 21.006-31.508 18.75-69.293 5.417-102.398.656-.31 1.324-.656 2-1.047 36.06-20.76 72.405-1.53 103.05 7.155-15.682-23.3-46.416-38.936-78.345-38.68zM210.58 244.42c19.455 0 35.22 15.766 35.22 35.22 0 19.44-15.765 35.22-35.22 35.22-19.44 0-35.22-15.764-35.22-35.22 0-19.44 15.765-35.22 35.22-35.22zm90.84 0c19.44 0 35.22 15.766 35.22 35.22 0 19.44-15.765 35.22-35.22 35.22-19.44 0-35.22-15.764-35.22-35.22 0-19.44 15.765-35.22 35.22-35.22zm-97.006 8.97c-9.72 0-17.61 7.89-17.61 17.61 0 9.72 7.89 17.61 17.61 17.61 9.72 0 17.61-7.89 17.61-17.61 0-9.72-7.89-17.61-17.61-17.61zm90.842 0c-9.72 0-17.61 7.89-17.61 17.61 0 9.72 7.89 17.61 17.61 17.61 9.72 0 17.61-7.89 17.61-17.61 0-9.72-7.89-17.61-17.61-17.61zm-69.182 35.43c-4.86 0-8.804 3.945-8.804 8.805 0 4.86 3.944 8.805 8.804 8.805s8.807-3.945 8.807-8.805c0-4.86-3.946-8.805-8.806-8.805zm90.84 0c-4.86 0-8.805 3.945-8.805 8.805 0 4.86 3.944 8.805 8.804 8.805s8.807-3.945 8.807-8.805c0-4.86-3.946-8.805-8.806-8.805z" fill="#fff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;"><g class="" transform="translate(0,0)" style="touch-action: none;"><path d="M256 27c-28.334 0-54.153 8.54-73.283 22.89C163.587 64.236 151 84.874 151 108c0 8.204 1.796 15.548 4.975 21.975 2.398 5.19 5.692 9.893 9.95 13.757 1.386 1.213 2.82 2.35 4.294 3.43 4.322 3.357 9.202 6.14 14.473 8.31 19.476 8.01 44.305 10 71.307 10 3.78 0 7.51-.045 11.197-.134 8.767-.154 17.47-.64 25.965-1.713 12.52-1.48 24.056-4.003 34.145-8.154 3.58-1.473 6.982-3.23 10.152-5.257 1.413-.782 2.815-1.59 4.192-2.45 5.74-4.175 10.267-9.775 13.512-16.132 3.15-5.776 5.153-12.34 5.688-19.644.216-2.173.32-4.358.285-6.54-.065-.015-.13-.03-.196-.048-.903-22.068-13.247-41.702-31.657-55.51C310.153 35.542 284.333 27 256 27zm0 18c24.686 0 46.868 7.578 62.482 19.29C334.097 76 343 91.36 343 108s-7.273 24.542-22.543 30.824c-15.27 6.283-38.44 8.65-64.457 8.65-26.017 0-49.187-2.367-64.457-8.65C176.273 132.542 169 124.64 169 108s8.903-32 24.518-43.71C209.132 52.577 231.314 45 256 45zm-37.775 17.748c-6.138.054-12.69 2.517-18.168 6.828-11.194 8.808-14.907 22.76-8.295 31.162 6.612 8.402 21.046 8.07 32.238-.738 11.193-8.81 14.906-22.76 8.293-31.162-3.115-3.957-8.16-6.142-14.068-6.09zm-85.29 47.78c-11.378 3.587-21.944 7.64-31.537 12.095C62.448 140.707 41 164.52 41 188c0 23.48 21.448 47.293 60.398 65.377C140.348 271.46 195.273 283 256 283c60.727 0 115.65-11.54 154.602-29.623C449.552 235.293 471 211.48 471 188c0-23.48-21.448-47.293-60.398-65.377-9.533-4.426-20.028-8.457-31.325-12.025-.997 20.097-10.243 39.685-27.293 51.935l-.222.16-.233.147c-33.465 21.076-73.328 21.37-108.768 20.252-29.29-.734-63.383-3.588-88.776-25.88l-.05-.046-.05-.045c-13.61-12.312-20.22-29.268-20.95-46.59zm290.116 47.23c7.672.046 15.3 2.61 20.97 8.28 6.98 6.978 9.254 16.924 7.92 26.265-1.335 9.34-6.04 18.522-13.577 26.06-7.538 7.538-16.72 12.242-26.06 13.576-9.34 1.334-19.287-.94-26.266-7.92-6.98-6.98-9.252-16.923-7.918-26.264 1.334-9.34 6.037-18.523 13.575-26.06 7.538-7.54 16.72-12.242 26.06-13.577 1.752-.25 3.525-.373 5.296-.362zm-336.042 1.94c1.77-.01 3.543.114 5.295.364 9.34 1.335 18.524 6.037 26.062 13.575 7.538 7.538 12.24 16.72 13.574 26.062 1.334 9.34-.94 19.284-7.92 26.263-6.978 6.98-16.92 9.25-26.262 7.916-9.34-1.336-18.525-6.037-26.063-13.575-7.538-7.538-12.24-16.722-13.574-26.063-1.333-9.34.94-19.284 7.92-26.263 5.67-5.672 13.297-8.235 20.968-8.28zm336.78 16.046c-1.078-.044-2.238.017-3.485.195-4.99.712-10.922 3.523-15.88 8.482-4.96 4.958-7.77 10.89-8.484 15.88-.713 4.99.432 8.598 2.826 10.99 2.393 2.394 6 3.54 10.992 2.827 4.99-.714 10.918-3.527 15.877-8.485 4.958-4.96 7.77-10.887 8.484-15.877.712-4.99-.434-8.6-2.827-10.992-1.795-1.795-4.274-2.888-7.506-3.022zM86.27 177.686c-3.232.133-5.71 1.226-7.504 3.02-2.394 2.394-3.54 6-2.828 10.99.712 4.992 3.527 10.923 8.486 15.882 4.958 4.96 10.886 7.77 15.877 8.483 4.99.713 8.6-.432 10.993-2.826 2.393-2.393 3.54-6 2.826-10.99s-3.525-10.922-8.483-15.88c-4.96-4.96-10.89-7.77-15.88-8.483-1.25-.177-2.41-.24-3.487-.194zM256 211c10.66 0 20.48 3.17 28.027 8.83C291.577 225.492 297 234.13 297 244c0 9.87-5.424 18.508-12.973 24.17C276.48 273.83 266.66 277 256 277c-10.66 0-20.48-3.17-28.027-8.83C220.423 262.508 215 253.87 215 244c0-9.87 5.424-18.508 12.973-24.17C235.52 214.17 245.34 211 256 211zm0 18c-7.013 0-13.194 2.204-17.227 5.23-4.033 3.023-5.773 6.385-5.773 9.77s1.74 6.747 5.773 9.77c4.033 3.026 10.214 5.23 17.227 5.23s13.194-2.204 17.227-5.23c4.033-3.023 5.773-6.385 5.773-9.77s-1.74-6.747-5.773-9.77C269.194 231.203 263.013 229 256 229zm-55.1 68.898L112 480h288l-88.9-182.102C293.433 299.925 274.988 301 256 301s-37.433-1.075-55.1-3.102z" fill="#fff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

@ -79,6 +79,7 @@ Connection.prototype.onReceiveMessage = function({ data }) {
case 'start': eventName = 'G-start'; break;
case 'stop': eventName = 'G-stop'; break;
case 'walls': eventName = 'G-walls'; break;
case 'winstate': eventName = 'G-winstate'; break;
}
if (eventName) {

65
client/controls.js vendored

@ -1,5 +1,4 @@
// //===== Constructor
//===== Constructor
const Controls = function() {
this.names = {};
// this.starts = [];
@ -11,7 +10,6 @@ const Controls = function() {
// document.addEventListener('L-reset', this.msgReset.bind(this));
// document.addEventListener('L-undo', this.msgUndo.bind(this));
// document.addEventListener('G-attempt', this.msgAttempt.bind(this));
// document.addEventListener('G-guess', this.msgGuess.bind(this));
document.addEventListener('G-players', this.msgPlayers.bind(this));
document.addEventListener('G-skip', this.msgSkip.bind(this));
@ -77,32 +75,15 @@ const Controls = function() {
// document.getElementById('controls-panic').style.display = '';
// };
// //===== Message handlers
// Controls.prototype.msgAttempt = function() {
// alert("Ready for winning attempt!");
// };
//===== Message handlers
// Controls.prototype.msgConnected = function() {
// this.showWaiting();
// };
// Controls.prototype.msgUndo = function(evt) {
// if (this.moves.length <= this.starts.length) {
// return;
// }
// const { id } = this.moves.pop();
// const indexOfPreviousMove = this.moves.reduce((acc, v, i) => (v.id === id ? i : acc), -1);
// const previousMove = this.moves.splice(indexOfPreviousMove, 1);
// const evtMove = new CustomEvent('L-move', { detail: previousMove[0] });
// document.dispatchEvent(evtMove);
// };
Controls.prototype.msgStack = function(evt) {
const moveCount = evt.detail.length;
const robots = evt.detail.reduce((acc, { id }) => acc.has(id) ? acc : acc.add(id), new Set());
const moveCount = evt.detail.length - robots.size;
document.getElementById('controls-moves').innerHTML = moveCount;
document.getElementById('controls-undo').style.display = moveCount > 0 ? 'block' : 'none';
@ -142,15 +123,6 @@ Controls.prototype.msgPlayers = function(evt) {
});
};
// Controls.prototype.msgReset = function() {
// // Broadcast starting locations.
// this.moves = [];
// this.starts.forEach(move => {
// const evtMove = new CustomEvent('L-move', { detail: move });
// document.dispatchEvent(evtMove);
// });
// };
Controls.prototype.msgSkip = function() {
// this.coundownComplete();
};
@ -223,4 +195,31 @@ Controls.prototype.onClickWalls = function() {
// document.getElementById('controls-panic').querySelector('.controls-alert-urgent').innerHTML = (`${this.names[msg.id]}${blurb}${guess} moves.`);
// this.showPanic();
// this.countdownStart(5);
// }
// }
// Controls.prototype.msgReset = function() {
// // Broadcast starting locations.
// this.moves = [];
// this.starts.forEach(move => {
// const evtMove = new CustomEvent('L-move', { detail: move });
// document.dispatchEvent(evtMove);
// });
// };
// Controls.prototype.msgUndo = function(evt) {
// if (this.moves.length <= this.starts.length) {
// return;
// }
// const { id } = this.moves.pop();
// const indexOfPreviousMove = this.moves.reduce((acc, v, i) => (v.id === id ? i : acc), -1);
// const previousMove = this.moves.splice(indexOfPreviousMove, 1);
// const evtMove = new CustomEvent('L-move', { detail: previousMove[0] });
// document.dispatchEvent(evtMove);
// };
// Controls.prototype.msgAttempt = function() {
// alert("Ready for winning attempt!");
// };

@ -2,17 +2,22 @@
const Grid = function() {
this.colors = {};
this.icons = {};
this.obstacles = {};
this.robots = [];
this.shadows = [];
this.walls = [];
this.winstate = {};
this.squaresPerSide = 20;
this.squareSideLength = 0;
document.addEventListener('L-stack', this.msgStack.bind(this));
document.addEventListener('L-shadows', this.msgShadows.bind(this));
document.addEventListener('G-robots', this.msgRobots.bind(this));
document.addEventListener('G-walls', this.msgWalls.bind(this));
document.addEventListener('G-winstate', this.msgWinState.bind(this));
window.addEventListener('resize', this.debounce(this.onResize.bind(this), 500));
@ -73,27 +78,69 @@ Grid.prototype.drawWalls = function() {
};
Grid.prototype.drawRobots = function() {
const s = this.squareSideLength;
const ids = new Set();
this.robots.forEach(({ id, i, j }) => {
const robot = document.getElementById(`robot-${id}`) || this.drawRobot({ id, i, j });
robot.style.left = `${i * s}px`;
robot.style.top = `${j * s}px`;
ids.add(robot.id);
});
const grid = document.getElementById('content-grid');
grid.querySelectorAll('.content-robot').forEach(el => {
if (ids.has(el.id) === false) {
el.parentNode.removeChild(el);
}
});
};
Grid.prototype.drawRobot = function({ id, i, j }) {
const grid = document.getElementById('content-grid');
grid.querySelectorAll('.content-robot').forEach(el => el.parentNode.removeChild(el));
const color = this.colors[id];
const s = this.squareSideLength;
// const robot = document.createElement('div');
const robot = document.createElement('img');
robot.src = this.icons[id];
robot.className = 'content-robot';
robot.id = `robot-${id}`;
robot.style.background = color;
robot.style.height = `${s}px`;
robot.style.width = `${s}px`;
grid.appendChild(robot);
return robot;
};
Grid.prototype.drawShadows = function() {
const grid = document.getElementById('content-grid');
grid.querySelectorAll('.content-shadow').forEach(el => el.parentNode.removeChild(el));
const s = this.squareSideLength;
this.robots.forEach(({ id, i, j }) => {
this.shadows.forEach(({ id, i, j }) => {
const color = this.colors[id];
const robot = document.createElement('div');
robot.className = 'content-robot';
const shadow = document.createElement('img');
shadow.src = this.icons[id];
shadow.className = 'content-shadow';
robot.style.background = `radial-gradient(circle at ${s/3}px ${s/3}px, ${color} 10%, #000)`;
robot.style.borderRadius = (s / 2) + 'px';
shadow.style.background = color;
robot.style.height = s + 'px';
robot.style.width = s + 'px';
shadow.style.height = `${s}px`;
shadow.style.width = `${s}px`;
robot.style.left = `${i * s}px`;
robot.style.top = `${j * s}px`;
shadow.style.left = `${i * s}px`;
shadow.style.top = `${j * s}px`;
grid.appendChild(robot);
grid.appendChild(shadow);
});
};
@ -138,9 +185,9 @@ Grid.prototype.drawArrow = function({ direction, label, left, top, parentId }) {
arrow.style.left = left + 'px';
arrow.style.top = top + 'px';
arrow.style.lineHeight = s + 'px';
arrow.style.height = s + 'px';
arrow.style.width = s + 'px';
arrow.style.lineHeight = `${s}px`;
arrow.style.height = `${s}px`;
arrow.style.width = `${s}px`;
arrow.dataset.direction = direction;
arrow.dataset.parent = parentId;
@ -150,6 +197,38 @@ Grid.prototype.drawArrow = function({ direction, label, left, top, parentId }) {
return arrow;
};
Grid.prototype.drawWinState = function() {
if (this.winstate.i === undefined || this.winstate.j === undefined) {
return;
}
const s = this.squareSideLength;
const grid = document.getElementById('content-grid');
grid.querySelectorAll('.content-winstate').forEach(el => el.parentNode.removeChild(el));
const star = document.createElementNS("http://www.w3.org/2000/svg", "svg");
star.setAttribute("viewBox", '0 0 100 100');
const path = document.createElementNS("http://www.w3.org/2000/svg", 'path');
path.setAttribute('d', "M 0,38 L 38,38 L 49,0 L 60,38 L 100,38 L 68,66 L 77,100 L 47,79 L 17,100 L 28,64 Z");
path.setAttribute('stroke-linecap', 'null');
path.setAttribute('stroke-linejoin', 'null');
path.setAttribute('stroke-dasharray', 'null');
path.setAttribute('stroke-width', '0');
path.setAttribute('fill', this.colors[this.winstate.id]);
star.appendChild(path);
star.style.position = 'absolute';
star.style.zIndex = 100;
star.style.left = '50%'
star.style.top = '50%'
star.style.height = `${s}px`;
star.style.width = `${s}px`;
grid.appendChild(star);
};
//===== Obstacle logic
// i and j are notations for the grid of squares.
// x and y are notations for absolute pixels.
@ -238,6 +317,15 @@ Grid.prototype.findNextObstacle = function({ direction, i, j }) {
throw Error("Could not find next obstacle, no direction found. ", direction, i, j);
};
Grid.prototype.checkWin = function({ id, i, j }) {
if (i !== this.winstate.i || j !== this.winstate.j || id !== this.winstate.id) {
return;
}
const evtSolve = new Event('L-solve');
document.dispatchEvent(evtSolve);
};
//===== DOM event handlers
Grid.prototype.onArrowClick = function(evt) {
@ -252,6 +340,8 @@ Grid.prototype.onArrowClick = function(evt) {
const evtMove = new CustomEvent('L-arrow', { detail: { id, i, j } });
document.dispatchEvent(evtMove);
this.checkWin({ id, i, j });
};
Grid.prototype.onResize = function() {
@ -281,6 +371,8 @@ Grid.prototype.onResize = function() {
this.drawWalls();
this.drawRobots();
this.drawArrows();
this.drawShadows();
this.drawWinState();
this.updateArrowVisibilities();
};
@ -296,6 +388,17 @@ Grid.prototype.debounce = function(fn, ms) {
//===== Message handlers
Grid.prototype.msgRobots = function(evt) {
// Do not assign position or redraw here: movements are fully managed using the stack.
this.colors = {};
this.icons = {};
evt.detail.body.forEach(({ id, color, icon }) => {
this.colors[id] = color;
this.icons[id] = icon;
}, {});
};
Grid.prototype.msgStack = function(evt) {
const latestPositions = evt.detail.reduce((acc, { id, i, j }) => {
acc[id] = { id, i, j };
@ -311,6 +414,11 @@ Grid.prototype.msgStack = function(evt) {
this.updateArrowVisibilities();
};
Grid.prototype.msgShadows = function(evt) {
this.shadows = evt.detail;
this.drawShadows();
};
Grid.prototype.msgWalls = function(evt) {
this.walls = evt.detail.body;
@ -320,15 +428,11 @@ Grid.prototype.msgWalls = function(evt) {
this.updateArrowVisibilities();
};
Grid.prototype.msgRobots = function(evt) {
// Do not assign position or redraw here: movements are fully managed using the stack.
this.colors = evt.detail.body.reduce((acc, { color, id }) => {
acc[id] = color;
return acc;
}, {});
Grid.prototype.msgWinState = function(evt) {
this.winstate = evt.detail.body;
this.drawWinState();
};
//============ THE TRASH BIN OF HISTORY
// Content.prototype.drawRobot = function({ id, i, j }) {
// const robot = document.getElementById(`robot-${id}`);

@ -0,0 +1,39 @@
const Icons = {
comet: (color) => {
// const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
// star.setAttribute("viewBox", '0 0 100 100');
// const path = document.createElementNS("http://www.w3.org/2000/svg", 'path');
const obj = document.getElementById('TEST_OBJECT_SVG');
console.log(obj);
console.log(obj.contentDocument)
return obj;
},
moon: (color) => {
},
planet: (color) => {
},
rocket: (color) => {
},
spacesuit: (color) => {
},
spider: (color) => {
},
ufo: (color) => {
},
};

@ -7,6 +7,7 @@ const Stack = function() {
document.addEventListener('L-arrow', this.msgArrow.bind(this));
document.addEventListener('L-undo', this.msgUndo.bind(this));
document.addEventListener('L-reset', this.msgReset.bind(this));
document.addEventListener('G-robots', this.msgRobots.bind(this));
};
@ -27,6 +28,9 @@ Stack.prototype.msgRobots = function(evt) {
const evtStack = new CustomEvent('L-stack', { detail: this.moves });
document.dispatchEvent(evtStack);
const evtShadows = new CustomEvent('L-shadows', { detail: this.moves });
document.dispatchEvent(evtShadows);
};
Stack.prototype.msgArrow = function(evt) {
@ -39,8 +43,6 @@ Stack.prototype.msgArrow = function(evt) {
Stack.prototype.msgReset = function() {
this.moves = this.getInitialPositions();
console.log(this.moves)
const evtStack = new CustomEvent('L-stack', { detail: this.moves });
document.dispatchEvent(evtStack);
};

@ -37,8 +37,22 @@
}
.content-robot {
padding: 4px;
position: absolute;
transition: left 0.4s cubic-bezier(0,1,.5,1), top 0.4s cubic-bezier(0,1,.5,1);
z-index: 2;
}
.content-shadow {
opacity: 0.2;
padding: 4px;
position: absolute;
transition: left 0.4s cubic-bezier(0,1,.5,1), top 0.4s cubic-bezier(0,1,.5,1);
z-index: 1;
}
.content-winstate {
position: absolute;
z-index: 1;
}

@ -6,13 +6,14 @@
<title>Robots</title>
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="controls.css">
<link rel="stylesheet" href="content.css">
<link rel="stylesheet" href="grid.css">
<link rel="stylesheet" href="join.css">
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<script type='text/javascript' src='client/connection.js'></script>
<script type='text/javascript' src='client/controls.js'></script>
<script type='text/javascript' src='client/cookie.js'></script>
<script type='text/javascript' src='client/grid.js'></script>
<script type='text/javascript' src='client/icons.js'></script>
<script type='text/javascript' src='client/join.js'></script>
<script type='text/javascript' src='client/stack.js'></script>
</head>

@ -11,5 +11,6 @@
"dependencies": {
"node-uuid": "^1.4.8",
"ws": "^7.3.0"
}
},
"devDependencies": {}
}

@ -67,6 +67,7 @@ const Server = {
Server.messageAll({ type: 'players', body: G.getPlayers() });
Server.messageOne(ws, { type: 'walls', body: G.getWalls()});
Server.messageOne(ws, { type: 'robots', body: G.getRobots()});
Server.messageOne(ws, { type: 'winstate', body: G.getWinState()});
Server.messageOne(ws, { type: 'connected', body: ws.id});
},
@ -126,4 +127,4 @@ const Server = {
wss.on('connection', Server.onConnect);
console.log("Websocket server listening on :8080")
console.log("Websocket server listening on :8080");

@ -6,6 +6,14 @@ const Game = function() {
this.id = uuid.v4();
this.countdownTimer = null;
this.guess = Infinity;
this.squaresPerSide = 20;
const robots = ['#E00000', '#00C000', '#0000FF', '#00C0C0', '#F000F0'];
const icons = ['assets/comet.svg', 'assets/moon.svg', 'assets/planet.svg', 'assets/rocket.svg', 'assets/spacesuit.svg'];
// spider.svg, ufo.svg
const gen = () => Math.floor(Math.random() * this.squaresPerSide);
this.TEMP_ROBOTS = robots.map((color, idx) => ({ i: gen(), j: gen(), color, id: uuid.v4(), icon: icons[idx] }));
}
Game.prototype.addPlayer = function(id, name) {
@ -24,20 +32,7 @@ Game.prototype.getPlayers = function() {
}
Game.prototype.getRobots = function() {
const robots = ['#E00000', '#00C000', '#0000FF', '#00C0C0', '#F000F0'];
const squaresPerSide = 20;
const gen = () => Math.floor(Math.random() * squaresPerSide);
// Leave here for testing.
// return [
// {i: 9, j: 9, color: '#E00000' },
// {i: 18, j: 9, color: '#00C000' },
// {i: 1, j: 9, color: '#0000FF' },
// {i: 9, j: 18, color: '#00C0C0' },
// {i: 9, j: 1, color: '#F000F0' },
// ];
return robots.map(color => ({ i: gen(), j: gen(), color, id: uuid.v4() }));
return this.TEMP_ROBOTS;
}
Game.prototype.getWalls = function() {
@ -54,11 +49,10 @@ Game.prototype.getWalls = function() {
// console.log("Generating walls.");
// Squares per side has quadratic relationship with wall/corner requirements.
const squaresPerSide = 20;
const numberOfCorners = Math.ceil(Math.pow((squaresPerSide / 10), 2));
const numberOfWalls = Math.ceil(Math.pow((squaresPerSide / 5), 2));
const numberOfCorners = Math.ceil(Math.pow((this.squaresPerSide / 10), 2));
const numberOfWalls = Math.ceil(Math.pow((this.squaresPerSide / 5), 2));
const gen = () => Math.floor(Math.random() * squaresPerSide);
const gen = () => Math.floor(Math.random() * this.squaresPerSide);
const edges = [];
// DO NUMBER OF CORNERS FIRST AFTER TESTING
@ -97,6 +91,12 @@ Game.prototype.getWalls = function() {
return edges;
};
Game.prototype.getWinState = function() {
// const gen = () => Math.floor(Math.random() * this.squaresPerSide);
return { i: 0, j: 0, id: this.TEMP_ROBOTS[0].id };
};
Game.prototype.onGuess = function(guess) {
return new Promise((resolve, reject) => {
const timeIsUp = () => {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Loading…
Cancel
Save