A_N_T_I_C_L_O_N
#1
Mantiqiy savolar yozamiz javob beramaiz
10 soat 46 daqiqa 6 soniyadan keyin yozdi:
Diqqat savol u yashash uchun uyidan vohli chiqib ketadi yasash uchun kopgina konsertlar beradi va ohirgi konserti fojiyali yakun topadi topganlar shaxsiy xabarga yozsin #1 deb
1 kun 10 soat 25 daqiqa 21 soniyadan keyin yozdi:
U savol emas lekin hamma unga javob beradi #2 deb yozila javobi
1 kun 10 soat 25 daqiqa 54 soniyadan keyin yozdi:
  1. <!DOCTYPE html>
  2. html, body {
  3. height: 100%;
  4. margin: 0;
  5. }
  6. body {
  7. background: black;
  8. display: flex;
  9. align-items: center;
  10. justify-content: center;
  11. }
  12. canvas {
  13. border: 1px solid white;
  14. }
  15. </style>
  16. </head>
  17. <canvas width="400" height="400" id="game"></canvas>
  18. var canvas = document.getElementById('game');
  19. var context = canvas.getContext('2d');
  20. var grid = 16;
  21. var count = 0;
  22.  
  23. var snake = {
  24. x: 160,
  25. y: 160,
  26.  
  27. // snake velocity. moves one grid length every frame in either the x or y direction
  28. dx: grid,
  29. dy: 0,
  30.  
  31. // keep track of all grids the snake body occupies
  32. cells: [],
  33.  
  34. // length of the snake. grows when eating an apple
  35. maxCells: 4
  36. };
  37. var apple = {
  38. x: 320,
  39. y: 320
  40. };
  41. // get random whole numbers in a specific range
  42. // @see https://stackoverflow.com/a/1527820/2124254
  43. function getRandomInt(min, max) {
  44. return Math.floor(Math.random() * (max - min)) + min;
  45. }
  46. // game loop
  47. function loop() {
  48. requestAnimationFrame(loop);
  49. // slow game loop to 15 fps instead of 60 (60/15 = 4)
  50. if (++count < 4) {
  51. return;
  52. }
  53. count = 0;
  54. context.clearRect(0,0,canvas.width,canvas.height);
  55. // move snake by it's velocity
  56. snake.x += snake.dx;
  57. snake.y += snake.dy;
  58. // wrap snake position horizontally on edge of screen
  59. if (snake.x < 0) {
  60. snake.x = canvas.width - grid;
  61. }
  62. else if (snake.x >= canvas.width) {
  63. snake.x = 0;
  64. }
  65.  
  66. // wrap snake position vertically on edge of screen
  67. if (snake.y < 0) {
  68. snake.y = canvas.height - grid;
  69. }
  70. else if (snake.y >= canvas.height) {
  71. snake.y = 0;
  72. }
  73. // keep track of where snake has been. front of the array is always the head
  74. snake.cells.unshift({x: snake.x, y: snake.y});
  75. // remove cells as we move away from them
  76. if (snake.cells.length > snake.maxCells) {
  77. snake.cells.pop();
  78. }
  79. // draw apple
  80. context.fillStyle = 'red';
  81. context.fillRect(apple.x, apple.y, grid-1, grid-1);
  82. // draw snake one cell at a time
  83. context.fillStyle = 'green';
  84. snake.cells.forEach(function(cell, index) {
  85.  
  86. // drawing 1 px smaller than the grid creates a grid effect in the snake body so you can see how long it is
  87. context.fillRect(cell.x, cell.y, grid-1, grid-1);
  88. // snake ate apple
  89. if (cell.x === apple.x && cell.y === apple.y) {
  90. snake.maxCells++;
  91. // canvas is 400x400 which is 25x25 grids
  92. apple.x = getRandomInt(0, 25) * grid;
  93. apple.y = getRandomInt(0, 25) * grid;
  94. }
  95. // check collision with all cells after this one (modified bubble sort)
  96. for (var i = index + 1; i < snake.cells.length; i++) {
  97.  
  98. // snake occupies same space as a body part. reset game
  99. if (cell.x === snake.cells[i].x && cell.y === snake.cells[i].y) {
  100. snake.x = 160;
  101. snake.y = 160;
  102. snake.cells = [];
  103. snake.maxCells = 4;
  104. snake.dx = grid;
  105. snake.dy = 0;
  106. apple.x = getRandomInt(0, 25) * grid;
  107. apple.y = getRandomInt(0, 25) * grid;
  108. }
  109. }
  110. });
  111. }
  112. // listen to keyboard events to move the snake
  113. document.addEventListener('keydown', function(e) {
  114. // prevent snake from backtracking on itself by checking that it's
  115. // not already moving on the same axis (pressing left while moving
  116. // left won't do anything, and pressing right while moving left
  117. // shouldn't let you collide with your own body)
  118. // left arrow key
  119. if (e.which === 37 && snake.dx === 0) {
  120. snake.dx = -grid;
  121. snake.dy = 0;
  122. }
  123. // up arrow key
  124. else if (e.which === 38 && snake.dy === 0) {
  125. snake.dy = -grid;
  126. snake.dx = 0;
  127. }
  128. // right arrow key
  129. else if (e.which === 39 && snake.dx === 0) {
  130. snake.dx = grid;
  131. snake.dy = 0;
  132. }
  133. // down arrow key
  134. else if (e.which === 40 && snake.dy === 0) {
  135. snake.dy = grid;
  136. snake.dx = 0;
  137. }
  138. });
  139. // start the game
  140. requestAnimationFrame(loop);
  141. </script>
  142. </body>
  143. </html>
Tolik
#2
A_N_T_I_C_L_O_N, # A_N_T_I_C_L_O_N (03.01.2019 / 12:05)
Mantiqiy savolar yozamiz javob beramaiz
10 soat 46 daqiqa 6 soniyadan keyin yozdi:
Diqqat savol u yashash uchun uyidan vohli chiqib ketadi yasash uchun kopgina konsertlar beradi va ohirgi konserti
Bu kodni mantiqiy savollarga qanday aloqasi bor?
A_N_T_I_C_L_O_N
#3
Tolik, Yozilib ketdi
Nodirali
#4
Kecha ko'chada taksiga o'tirdim. Yana bir kishi kelsa ketamiz dedi. Xo'p dedim. Sal o'tib asablarim taranglashib, g'azabimni jilovlab mashinadan tushib keyingi taksiga 1-odam bo'lib mindim. Keyin qiziq boshlandi. 2ta taksist urushib ketdi. Urush sababchisi esa hotirjam mashinada odam kutib o'tiribdi ya'ni men.

Mashinadan tushishimga sabab nima deb o'ylaysiz?
AkCenT
#5
Tuvakda gul unga suv quysa nima bo'ladi
sobirjonovv
#6
Stakanga suv quyib undan keyin tuz solsa nima bo'ladi?
24
CHEfan
#7
AkCenT, Hamir.

P.S savolingiz noto'g'ri berilgan ekan.
24
CHEfan
#8
Mahmudjon_BEST, Buyam hamir buladi 😁
24
CHEfan
#9
A_N_T_I_C_L_O_N, #2 ism
4 daqiqa 54 soniyadan keyin yozdi:
2ta ota va 2ta o'g'il baliq ovida har biri 2 tadan baliq tutishadi. Ular jami qancha baliq tutishgan?
AkCenT
#10
CHEfan, # CHEfan (27.06.2019 / 03:17)
AkCenT, Hamir.

P.S savolingiz noto'g'ri berilgan ekan.
Javobingiz to'g'ri mantiqiy ku shunga shu tarzda savol yozdim
ŝჩσჩĵฉჩσฑ
#11
CHEfan, # CHEfan (27.06.2019 / 03:19)
A_N_T_I_C_L_O_N, #2 ism
4 daqiqa 54 soniyadan keyin yozdi:
2ta ota va 2ta o'g'il baliq ovida har biri 2 tadan baliq tutishadi. Ular jami qancha baliq tutishgan?
Javob: 6ta baliq
24
CHEfan
#12
AkCenT, Ha to'g'ri ammo savolni to'g'ri varianti bunaqa edi.

Tog'ara (likopcha) suv solib undan keyin tuz solib aralashtirsa nima bo'ladi?
AkCenT
#13
CHEfan, # CHEfan (27.06.2019 / 10:28)
AkCenT, Ha to'g'ri ammo savolni to'g'ri varianti bunaqa edi.

Tog'ara (likopcha) suv solib undan keyin tuz solib aralashtirsa nima bo'ladi?
Unda savol anq böladyu
ŝჩσჩĵฉჩσฑ
#14
Dunyoda bir narsa borki, u bo'lmasa hech kim bir birini taniy olmaydi. Nima?
BILINGUAL
#15
wizard, # wizard (27.06.2019 / 15:32)
Dunyoda bir narsa borki, u bo'lmasa hech kim bir birini taniy olmaydi. Nima?
Yuz yoki ism yoki ko'z
Apalon4ik
#16
wizard, # wizard (27.06.2019 / 15:32)
Dunyoda bir narsa borki, u bo'lmasa hech kim bir birini taniy olmaydi. Nima?
Ism
Apalon4ik
#17
Savol:
u dunyodagi barcha tilda gaplasha oladi. Faqat bir tilda gaplasga olmaydi. Savol qaysi tilda va sabab
ŝჩσჩĵฉჩσฑ
#18
SupReMe_MaSTeR, Aks sado
Apalon4ik
#19
wizard, # wizard (27.06.2019 / 19:53)
SupReMe_MaSTeR, Aks sado
Savolni öqing: qaysi tilda va sabab
nima emas
Apalon4ik
#20
Mashinalar necha qismga bo'linadi

Kunduzi: 29°C

18 Apr 2024 yil
Joylashuv aniqlanmadi