game.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Raid on river</title>
  6. <style></style>
  7. </head>
  8. <body>
  9. <canvas id="gameCanvas" width="1280" height="720"></canvas>
  10. <script type="text/javascript">
  11. const FPS = 60;
  12. const SCENE_SPEED = 3;
  13. const SPEED_INCREASE = 0.2; //увеличение скорсоти на
  14. const GEN_TIME = 5;
  15. const LIFES = 1;
  16. const PLANE_SIZE = 30; //plane height in pixels
  17. const PLANE_ACCELERATION = 2/5; //TODO пока пиксели в секунду
  18. const MISSLE_SPEED = 13; //TODO обдумать на размер сцены
  19. const MISSLE_SIZEY = 20/3*2; //длина снаряда
  20. const MISSLE_SIZEX = 5; //ширина снаряда
  21. const SHOOT_COOLDOWN = 3/8; //в секундах
  22. const SHIPS_COUNT = 5; //начальное кол-во кораблей
  23. const SHIP_SIZEY = 25; //высота корабля
  24. const SHIP_SIZEX = 100; //ширина корабля
  25. const CONTROL_START = 32;
  26. const CONTROL_LEFT = 90; //90 - Z
  27. const CONTROL_RIGHT = 88; //88 - X
  28. const CONTROL_FIRE = 190; //190 - ,
  29. const SHOW_BOUNDING = true;
  30. const GOD = false;
  31. /** @type {HTMLCanvasElement} */
  32. var canv = document.getElementById("gameCanvas");
  33. var ctx = canv.getContext("2d");
  34. var score = 0;
  35. var scene = { //хранит бэкраунд
  36. lifes: LIFES,
  37. speed: SCENE_SPEED,
  38. gameOver: false,
  39. genTimer: GEN_TIME * FPS,
  40. blocks: []
  41. //boundaries: []
  42. }
  43. addStartingBlock();
  44. var plane;
  45. newPlane();
  46. var ships = [];
  47. createShip();
  48. //set up event handler
  49. document.addEventListener("keydown", keyDown);
  50. document.addEventListener("keyup", keyUp);
  51. //game loop
  52. setInterval(update, 1000 / FPS);
  53. function addStartingBlock(){
  54. var block = {
  55. x: 0,
  56. y: 0,
  57. replaced: false,
  58. boundaries: [],
  59. }
  60. block.x = 0;
  61. block.y = -3 * 720;
  62. block.boundaries.push(addBounadry(0, block.y, 1280 / 4, 4 * 720));
  63. block.boundaries.push(addBounadry(1280 - 1280 / 4, block.y, 1280 / 4, 4 * 720));
  64. scene.blocks.push(block);
  65. }
  66. function addBounadry(bx,by,bw,bh){
  67. var boundary = {
  68. //replaced: false,
  69. collision: {
  70. x: bx,
  71. y: by,
  72. w: bw,
  73. h: bh,
  74. }
  75. }
  76. return boundary;
  77. }
  78. function createShip() {
  79. ships = [];
  80. for (var i = 0; i < 3; i++) {
  81. var ship = newShip();
  82. if (ship != null) {
  83. ships.push(ship);
  84. }
  85. }
  86. }
  87. //key events
  88. function keyDown(/** @type {KeyboardEvent} */ ev) {
  89. switch (ev.keyCode) {
  90. case CONTROL_LEFT: //Move to the left
  91. if (!scene.gameOver){
  92. plane.acceleration.negx = true;
  93. }
  94. break;
  95. case CONTROL_RIGHT: //Move to the right
  96. if (!scene.gameOver){
  97. plane.acceleration.posx = true;
  98. }
  99. break;
  100. case CONTROL_FIRE: //Fire the missle
  101. if (!scene.gameOver){
  102. plane.shooting = true;
  103. }
  104. break;
  105. case CONTROL_START:
  106. if (scene.gameOver){
  107. newGame();
  108. }
  109. break;
  110. }
  111. }
  112. function keyUp(/** @type {KeyboardEvent} */ ev) {
  113. switch (ev.keyCode) {
  114. case CONTROL_LEFT: //Move to the left
  115. if (!scene.gameOver){
  116. plane.acceleration.negx = false;
  117. }
  118. break;
  119. case CONTROL_RIGHT: //Move to the right
  120. if (!scene.gameOver){
  121. plane.acceleration.posx = false;
  122. }
  123. break;
  124. case CONTROL_FIRE: //Fire the missle
  125. if (!scene.gameOver){
  126. plane.shooting = false;
  127. }
  128. //plane.reload = false;
  129. break;
  130. }
  131. }
  132. function newGame() {
  133. console.log("New Game!");
  134. scene.blocks = [];
  135. addStartingBlock();
  136. newPlane();
  137. createShip();
  138. score = 0;
  139. scene.gameOver = false;
  140. scene.lifes = LIFES;
  141. scene.speed = SCENE_SPEED;
  142. scene.genTimer = GEN_TIME * FPS;
  143. }
  144. function newPlane() {
  145. plane = {
  146. x: canv.width / 2,
  147. y: canv.height / 2 + 100,
  148. r: PLANE_SIZE / 2,
  149. a: 90 / 180 * Math.PI,
  150. acceleration: {
  151. posx: false,
  152. negx: false,
  153. },
  154. speedx: 0,
  155. shooting: false,
  156. reload: false,
  157. reloadtime: 0,
  158. missles: [],
  159. collision: {
  160. x: 0,
  161. y: 0,
  162. w: PLANE_SIZE,
  163. h: PLANE_SIZE,
  164. },
  165. }
  166. }
  167. function newShip(x) {
  168. let direction
  169. if (Math.floor(Math.random()*2) == 0) {
  170. direction = -1;
  171. } else {
  172. direction = 1;
  173. }
  174. var ship = {
  175. x: 0,
  176. y: 0 - SHIP_SIZEY,
  177. a: direction,
  178. collision: {
  179. x: 0,
  180. y: 0,
  181. w: SHIP_SIZEX,
  182. h: SHIP_SIZEY,
  183. },
  184. }
  185. //console.log("shipgeneration");
  186. var shipPosGeneration = 0;
  187. while (shipPosGeneration != -1 && shipPosGeneration <= 10) {
  188. ship.x = Math.floor(Math.random()*1280);
  189. ship.collision.x = ship.x - SHIP_SIZEX / 2;
  190. shipPosGenerationInit = shipPosGeneration;
  191. for (var i = scene.blocks.length - 1; i >= 0 ; i--) {
  192. for (var j = scene.blocks[i].boundaries.length - 1; j >= 0 ; j--) {
  193. if (checkRectangularCollision(ship.collision, scene.blocks[i].boundaries[j].collision)) {
  194. shipPosGeneration++;
  195. i = -1;
  196. j = -1;
  197. }
  198. }
  199. }
  200. if (shipPosGeneration == shipPosGenerationInit) {
  201. for (var i = ships.length - 1; i >= 0; i--){
  202. if (checkRectangularCollision(ship.collision, ships[i].collision) ) {
  203. shipPosGeneration++;
  204. i = -1;
  205. }
  206. }
  207. }
  208. //console.log(shipPosGeneration);
  209. if (shipPosGeneration == shipPosGenerationInit) {
  210. shipPosGeneration = -1;
  211. }
  212. }
  213. if (shipPosGeneration >= 10) {
  214. return null;
  215. }
  216. console.log(ship.x);
  217. return ship;
  218. }
  219. function shootMissle() {
  220. if (!plane.reload && plane.shooting) {
  221. plane.missles.push({
  222. x: plane.x + 4 / 3 * plane.r * Math.cos(plane.a),
  223. y: plane.y - 4 / 3 * plane.r * Math.sin(plane.a),
  224. collision: {
  225. x: plane.x + 4 / 3 * plane.r * Math.cos(plane.a) - MISSLE_SIZEX / 2,
  226. y: plane.y - 4 / 3 * plane.r * Math.sin(plane.a),
  227. w: MISSLE_SIZEX,
  228. h: MISSLE_SIZEY,
  229. },
  230. })
  231. console.log("*shoot*");
  232. plane.reloadtime = SHOOT_COOLDOWN * FPS;
  233. plane.reload = true;
  234. }
  235. }
  236. function death() {
  237. scene.lifes--;
  238. ships = [];
  239. if (scene.lifes == 0) {
  240. console.log("Game Over!"); //в функции gameOver
  241. console.log("Your Score:");
  242. console.log(score);
  243. scene.gameOver = true;
  244. scene.speed = 0;
  245. }
  246. }
  247. function checkRectangularCollision(a, b){ //проверка коллизии 2х прямоугольных объекттов
  248. if (a.x < b.x + b.w &&
  249. a.x + a.w > b.x &&
  250. a.y < b.y + b.h &&
  251. a.h + a.y > b.y) {
  252. //console.log("collision detected");
  253. return true
  254. }
  255. else {
  256. //console.log("no collision");
  257. return false;
  258. }
  259. }
  260. function checkPlaneSceneCollision(x,y,c) { //проверка коллизии самолёта с сценой
  261. var collsion = {
  262. x: x + 4 / 3 * plane.r * Math.cos(plane.a) - PLANE_SIZE / 2,
  263. y: y - 4 / 3 * plane.r * Math.sin(plane.a),
  264. w: PLANE_SIZE,
  265. h: PLANE_SIZE,
  266. }
  267. //plane.collision.x =
  268. //plane.collision.y = plane.y - 4 / 3 * plane.r * Math.sin(plane.a)
  269. var problem = false;
  270. if (collsion.x < c.x + c.w &&
  271. collsion.x + collsion.w > c.x &&
  272. collsion.y < c.y + c.h &&
  273. collsion.h + collsion.y > c.y) {
  274. problem = true;
  275. }
  276. if (problem) {
  277. if (collsion.x + PLANE_SIZE / 2 <= (c.x + c.w + PLANE_SIZE / 2) && collsion.x + PLANE_SIZE / 2 >= c.x + c.w / 2) { //левостороняя коллизия
  278. return c.x + c.w + PLANE_SIZE / 2;
  279. }
  280. if (collsion.x + PLANE_SIZE / 2 > c.x - PLANE_SIZE / 2 && collsion.x + PLANE_SIZE / 2 < c.x + c.w / 2) { //правостороняя коллизия
  281. return c.x - plane.r;
  282. }
  283. }
  284. else {
  285. return 0;
  286. }
  287. return 1280/2;
  288. }
  289. function drawCollision(a, color) { //Рисует коллизию объекта
  290. ctx.strokeStyle = color;
  291. ctx.strokeRect(a.x, a.y, a.w, a.h);
  292. }
  293. function update() {
  294. //draw scene
  295. ctx.fillStyle = "black";
  296. ctx.fillRect(0,0, canv.width, canv.height)
  297. //отрисовка бэкграунда
  298. for (var i = 0; i < scene.blocks.length; i++) {
  299. for (var j = 0; j < scene.blocks[i].boundaries.length; j++) {
  300. if (SHOW_BOUNDING) {
  301. drawCollision(scene.blocks[i].boundaries[j].collision,"green");
  302. }
  303. }
  304. }
  305. //проверка коллизии
  306. //коллизия кораблей с самолётом
  307. for (var i = 0; i < ships.length; i++){
  308. if (checkRectangularCollision(ships[i].collision, plane.collision)) {
  309. console.log("Plane collading with ship no. " + i);
  310. if (!GOD) {
  311. death();
  312. }
  313. }
  314. }
  315. //коллизия снаряда с кораблями
  316. for (var i = ships.length - 1; i >= 0; i--){
  317. for (var j = plane.missles.length - 1; j >= 0; j--) {
  318. if (checkRectangularCollision(ships[i].collision, plane.missles[j].collision)) {
  319. console.log("Missle no. " + j + " collading with ship no. " + i )
  320. plane.missles.splice(j,1);
  321. ships.splice(i,1);
  322. score += 30;
  323. console.log("New score: " + score);
  324. var ship = newShip();
  325. if (ship != null) {
  326. ships.push(ship);
  327. }
  328. }
  329. }
  330. }
  331. //move scene
  332. //движение бэкграунда
  333. for (var i = scene.blocks.length - 1; i >= 0; i--) {
  334. if (scene.blocks[i].y > 720 ) { //удаление ушедшего блока
  335. scene.blocks.splice(i,1);
  336. continue;
  337. }
  338. if (scene.blocks[i].y > 0 && !scene.blocks[i].replaced) { //подстановка нового блока
  339. var block = {
  340. x: 0,
  341. y: scene.blocks[i].y - (4 * 720) + scene.speed,
  342. replaced: false,
  343. boundaries: [],
  344. }
  345. block.boundaries.push(addBounadry(0, block.y, 1280 / 4, 4 * 720));
  346. block.boundaries.push(addBounadry(1280 - 1280 / 4, block.y, 1280 / 4, 4 * 720));
  347. block.boundaries.push(addBounadry(1280 / 2 - 1280 / 8, block.y + 720, 1280 / 4, 2 * 720));
  348. block.boundaries.push(addBounadry(1280 / 2 - 1280 / 8 + PLANE_SIZE / 2, block.y + 720 - PLANE_SIZE / 2, 1280 / 4 - PLANE_SIZE, 2 * 720 + PLANE_SIZE));
  349. block.boundaries.push(addBounadry(1280 / 2 - 1280 / 8 + PLANE_SIZE, block.y + 720 - PLANE_SIZE, 1280 / 4 - 2 * PLANE_SIZE, 2 * 720 + 2 * PLANE_SIZE));
  350. scene.blocks.push(block);
  351. scene.blocks[i].replaced = true;
  352. }
  353. //движение блока, его баундари(TODO) и коллизий внутри
  354. scene.blocks[i].y += scene.speed;
  355. for (var j = scene.blocks[i].boundaries.length - 1; j >= 0; j--) {
  356. scene.blocks[i].boundaries[j].collision.y += scene.speed; //TODO двигать не только коллизию
  357. }
  358. }
  359. scene.genTimer--;
  360. //console.log(scene.genTimer);
  361. if (scene.genTimer == 0 && !scene.gameOver) {
  362. if (ships.length < SHIPS_COUNT) {
  363. var ship = newShip();
  364. if (ship != null) {
  365. ships.push(ship);
  366. }
  367. }
  368. scene.speed += SPEED_INCREASE;
  369. console.log("New speed:");
  370. console.log(scene.speed);
  371. scene.genTimer = 5 * FPS;
  372. }
  373. //двигаем объекты
  374. //двигаем корабли
  375. for (var i = ships.length - 1; i >= 0 ; i--){
  376. if (ships[i].y > 720 + SHIP_SIZEY / 2) { //удаление снарядов за экраном
  377. ships.splice(i,1);
  378. var ship = newShip();
  379. if (ship != null) {
  380. ships.push(ship);
  381. }
  382. continue;
  383. }
  384. ships[i].y += scene.speed;
  385. ships[i].collision.x = ships[i].x - SHIP_SIZEX / 2;
  386. ships[i].collision.y = ships[i].y - SHIP_SIZEY / 2;
  387. //console.log(ships[i].collision.w);
  388. }
  389. //рисуем корабли
  390. for (var i = 0; i < ships.length ; i++){
  391. ctx.beginPath();
  392. ctx.moveTo( //корабля
  393. ships[i].x + ships[i].a * (SHIP_SIZEX / 6),
  394. ships[i].y - SHIP_SIZEY / 2
  395. )
  396. ctx.lineTo(
  397. ships[i].x - ships[i].a * (SHIP_SIZEX / 20 ) + ships[i].a * (SHIP_SIZEX / 6),
  398. ships[i].y - SHIP_SIZEY / 2
  399. )
  400. ctx.lineTo(
  401. ships[i].x - ships[i].a * (SHIP_SIZEX / 13) + ships[i].a * (SHIP_SIZEX / 6),
  402. ships[i].y - SHIP_SIZEY / 4
  403. )
  404. ctx.lineTo(
  405. ships[i].x - ships[i].a * (SHIP_SIZEX / 5) + ships[i].a * (SHIP_SIZEX / 6),
  406. ships[i].y - SHIP_SIZEY / 4
  407. )
  408. ctx.lineTo(
  409. ships[i].x - ships[i].a * (SHIP_SIZEX / 3) + ships[i].a * (SHIP_SIZEX / 6),
  410. ships[i].y + SHIP_SIZEY / 6
  411. )
  412. ctx.lineTo(
  413. ships[i].x - ships[i].a * SHIP_SIZEX / 2,
  414. ships[i].y + SHIP_SIZEY / 6
  415. )
  416. ctx.lineTo(
  417. ships[i].x - ships[i].a * SHIP_SIZEX * 2 / 7,
  418. ships[i].y + SHIP_SIZEY / 2
  419. )
  420. ctx.lineTo(
  421. ships[i].x + ships[i].a * SHIP_SIZEX / 3,
  422. ships[i].y + SHIP_SIZEY / 2
  423. )
  424. ctx.lineTo(
  425. ships[i].x + ships[i].a * SHIP_SIZEX / 2 ,
  426. ships[i].y + SHIP_SIZEY / 6
  427. )
  428. ctx.lineTo(
  429. ships[i].x + ships[i].a * SHIP_SIZEX / 2 - ships[i].a * SHIP_SIZEX / 10 ,
  430. ships[i].y + SHIP_SIZEY / 6
  431. )
  432. ctx.lineTo(
  433. ships[i].x + ships[i].a * (SHIP_SIZEX / 6),
  434. ships[i].y - SHIP_SIZEY / 4
  435. )
  436. ctx.closePath();
  437. ctx.fillStyle = "red";
  438. ctx.fill();
  439. if (SHOW_BOUNDING) {
  440. ctx.strokeStyle = "lime";
  441. ctx.strokeRect(
  442. ships[i].x - SHIP_SIZEX / 2,
  443. ships[i].y - SHIP_SIZEY / 2,
  444. SHIP_SIZEX,
  445. SHIP_SIZEY
  446. )
  447. }
  448. }
  449. //draw plane
  450. //ctx.lineWidth = PLANE_SIZE / 20;
  451. ctx.beginPath();
  452. ctx.moveTo( //nose of the plane
  453. plane.x + 4 / 3 * plane.r * Math.cos(plane.a),
  454. plane.y - 4 / 3 * plane.r * Math.sin(plane.a)
  455. );
  456. ctx.lineTo( //rear left of the plane
  457. plane.x - plane.r * (2 / 3 * Math.cos(plane.a) + Math.sin(plane.a)),
  458. plane.y + plane.r * (2 / 3 * Math.sin(plane.a) - Math.cos(plane.a))
  459. );
  460. ctx.lineTo( //rear right of the plane
  461. plane.x - plane.r * (2 / 3 * Math.cos(plane.a) - Math.sin(plane.a)),
  462. plane.y + plane.r * (2 / 3 * Math.sin(plane.a) + Math.cos(plane.a))
  463. );
  464. ctx.closePath();
  465. ctx.fillStyle = "yellow";
  466. ctx.fill();
  467. //ctx.strokeStyle = "yellow";
  468. //ctx.stroke();
  469. if (SHOW_BOUNDING) {
  470. //console.log(plane.collision.x);
  471. drawCollision(plane.collision,"blue");
  472. }
  473. //Рисуем снаряды
  474. for (var i = 0; i < plane.missles.length; i++) {
  475. ctx.beginPath();
  476. ctx.moveTo( //верхушка снаряда
  477. plane.missles[i].x,
  478. plane.missles[i].y
  479. )
  480. ctx.lineTo( //левый верхний угол снаряда
  481. plane.missles[i].x - MISSLE_SIZEX / 2,
  482. plane.missles[i].y + MISSLE_SIZEX / 2
  483. )
  484. ctx.lineTo( //левый нижний угол снаряда
  485. plane.missles[i].x - MISSLE_SIZEX / 2,
  486. plane.missles[i].y + MISSLE_SIZEY
  487. )
  488. ctx.lineTo( //правый нижний угол снаряда
  489. plane.missles[i].x + MISSLE_SIZEX / 2,
  490. plane.missles[i].y + MISSLE_SIZEY
  491. )
  492. ctx.lineTo( //правый верхний угол снаряда
  493. plane.missles[i].x + MISSLE_SIZEX / 2,
  494. plane.missles[i].y + MISSLE_SIZEX / 2
  495. )
  496. ctx.closePath();
  497. //ctx.strokeStyle = "cyan";
  498. ctx.fillStyle = "cyan";
  499. ctx.fill();
  500. if (SHOW_BOUNDING) {
  501. drawCollision(plane.missles[i].collision,"pink");
  502. }
  503. }
  504. shootMissle();
  505. //update acceleration
  506. if (plane.acceleration.posx ^ plane.acceleration.negx){
  507. //console.log("acceleration calc")
  508. if (plane.acceleration.posx){
  509. if (plane.speedx > 0) plane.speedx = 0 //исключение "пьяного" замедления
  510. plane.speedx -= PLANE_ACCELERATION;
  511. }
  512. if (plane.acceleration.negx) {
  513. if (plane.speedx < 0) plane.speedx = 0 //исключение "пьяного" замедления
  514. plane.speedx += PLANE_ACCELERATION;
  515. }
  516. } else {
  517. plane.speedx = 0;
  518. }
  519. //move the plane
  520. //TODO размер сцены
  521. if (!scene.gameOver) {
  522. for (var i = 0; i < scene.blocks.length; i++) {
  523. for (var j = 0; j < scene.blocks[i].boundaries.length; j++) {
  524. var newPlaneX = checkPlaneSceneCollision(plane.x - plane.speedx, plane.y,scene.blocks[i].boundaries[j].collision)
  525. if (newPlaneX != 0){
  526. plane.speedx = 0;
  527. plane.x = newPlaneX;
  528. console.log("collsion with boundary no." + j + " in block no. " + i);
  529. }
  530. }
  531. }
  532. plane.x -= plane.speedx;
  533. }
  534. /*
  535. rightBorder = 1280;
  536. leftBorder = 0;
  537. if ((plane.x - plane.speedx) <= (rightBorder - plane.r) && (plane.x - plane.speedx) >= (0 + plane.r))
  538. { plane.x -= plane.speedx;
  539. } else {
  540. if ((plane.x - plane.speedx) > (rightBorder - plane.r)){
  541. plane.x =(rightBorder - plane.r);
  542. } else {
  543. if ((plane.x - plane.speedx) < (leftBorder + plane.r)) {
  544. plane.x = (leftBorder + plane.r);
  545. }
  546. }
  547. }
  548. */
  549. plane.collision.x = plane.x + 4 / 3 * plane.r * Math.cos(plane.a) - PLANE_SIZE / 2;
  550. plane.collision.y = plane.y - 4 / 3 * plane.r * Math.sin(plane.a)
  551. //двигаем снаряды
  552. for (var i = plane.missles.length - 1; i >= 0 ; i--) {
  553. if (plane.missles[i].y < 0 - MISSLE_SIZEY) { //удаление снарядов за экраном
  554. plane.missles.splice(i,1);
  555. continue;
  556. }
  557. plane.missles[i].y -= MISSLE_SPEED;
  558. plane.missles[i].collision.x = plane.missles[i].x - MISSLE_SIZEX / 2;
  559. plane.missles[i].collision.y = plane.missles[i].y;
  560. }
  561. if (plane.reload) { //перезарядка
  562. if (plane.reloadtime <= 0){
  563. console.log("reloaded");
  564. plane.reload = false;
  565. } else {
  566. plane.reloadtime--;
  567. }
  568. }
  569. }
  570. </script>
  571. </body>
  572. </html>