Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <%= render 'layouts/lobbyheader' %>
  2. <% provide(:button_text, 'Lobby') %>
  3. <% provide(:title_text, 'GAME') %>
  4.  
  5. <canvas id ="game_canvas">
  6. 'Your browser does not support the canvas element.'
  7. </canvas>
  8.  
  9. <script>
  10.  
  11. var canvas = document.getElementById("game_canvas");
  12. canvas.width = window.innerWidth;
  13. canvas.height = window.innerHeight;
  14. var ctx = canvas.getContext('2d');
  15. var countIt = 50.1
  16. setInterval(drawGame,1000);
  17. function drawGame() {
  18. drawGameBackground(ctx);
  19. drawGameCountDown(ctx,countIt);
  20. }
  21.  
  22. function drawGameBackground(ctx,countIt) {
  23. var x4 = .08 * window.innerWidth; // x pos of title
  24. var y4 = .10 * window.innerHeight; // y pos of title
  25. var x5 = .08 * window.innerWidth; // x pos of "MaxProfit"
  26. var y5 = y4 + .05 * window.innerHeight; // y pos of "Max Profit"
  27. var i = 0;
  28. var x = .06 * window.innerWidth; // start of line
  29. var x1 = .07 * window.innerWidth; //start of separators
  30. var y1 = .5 * window.innerHeight; // top of separators
  31. var y2 = y1 + .025 * window.innerHeight; // bottom of separators
  32. var z = .015 * window.innerWidth; // increment between separators
  33. var x2 = z * 21; // end of line
  34. var y = y1 + (.0125 * window.innerHeight); //midpoint of sep line
  35. var x6 = x1 - 5; // x start of the second lables
  36. var y3 = y2 + (.0125 * window.innerHeight); // y pos of sec labels
  37. var x7 = .18 * window.innerWidth; // x pos of the counter
  38. var y7 = .35 * window.innerHeight; // y position ofcounter
  39. var s; // second
  40. var x4 = .08 * window.innerWidth; // x position of "GAME"
  41. var y4 = .10 * window.innerHeight; // y position of "GAME"
  42. ctx.fillStyle = "#ffffff";
  43. ctx.fill();
  44. ctx.font = "35px Rock Salt";
  45. ctx.fillText("GAME", x4, y4);
  46. ctx.font = "15px Tahoma";
  47. ctx.fillText("Max Profit: 10 000 000 Coins", x5, y5);
  48. ctx.beginPath();
  49. ctx.moveTo(x,y);
  50. ctx.lineTo(x2,y);
  51. ctx.lineWidth = .5;
  52. ctx.strokeStyle = "#000000";
  53. ctx.lineWidth = 1;
  54. ctx.stroke();
  55. while (i < 17){
  56. s = i + 1;
  57. ctx.font = "10px Tahoma";
  58. ctx.fillText(s + "s", x6, y3);
  59. ctx.beginPath();
  60. ctx.moveTo(x1,y1);
  61. ctx.lineTo(x1,y2);
  62. x1 = x1 + z;
  63. x6 = x6 + z;
  64. ctx.strokeStyle = "#000000";
  65. ctx.lineWidth = 1;
  66. ctx.stroke();
  67. i++;
  68. }
  69. }
  70.  
  71. function drawGameCountDown(ctx, countIt) {
  72.  
  73. countIt = (countIt - .1).toFixed(1);
  74. ctx.fillStyle = "#ffffff";
  75. ctx.fill();
  76. ctx.font = "35px Tahoma";
  77. ctx.fillText(countIt, x7, y7);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement