Откомпилировал свои игры написанные 1991-1998 гг. Как понизить скорость? - QBasic

Узнай цену своей работы

Формулировка задачи:

Насколько я знаю минимальное значение Sleep и Timer 1 секунда. Если в каждую итерацию вставить такую задержку, то игры будут тормозить. Что делать? Может библиотечка есть, чтобы вставить задержку 10 миллисекунд? Пока в голову приходит только выбор задержки скорости в самом начале игры. Выбранное значение, например 500 000, используется для пустого цикла for i=0 to 500000: next Но так как в QuckBASIC 4.5 не было опроса сенсорной клавиатуры, то непонятно как выбрать задержку потянув за бегунок пальцем. Кто сталкивался с такими проблемами в QB64?

Решение задачи: «Откомпилировал свои игры написанные 1991-1998 гг. Как понизить скорость?»

textual
Листинг программы
  1. DATA 3,3,2,8,8,8,7,4,4,2,1,2,4,4,4,4,4,4,3,3,8,8,8,8,8,8,8,8
  2. DATA 7,7,6,6,4,4,4,6,7,7,7,7,6,7,2,3,6,6
  3. DATA 6,6,6,6,6,4,4,3,6,6,6,6,6,6,6,8,10,10,9,7,3,2,4,5,7,7,7,7,7,7,7,6,6,6
  4. DIM a(500), B(500), c(1000), e(1000), w(10000), w1(1000), z(100), m(100), t(100), v(100)
  5. SCREEN 1, 0
  6. PRESET (205, 20)
  7. DRAW "c2d15e5g5h5"
  8. 9
  9. LINE (155, y5)-(165, y5), 2
  10. a$ = INKEY$
  11. IF a$ = "2" AND y5 < 199 THEN y5 = y5 + 1
  12. IF a$ = "q" OR a$ = "Q" THEN END
  13. 'IF NOT a$ = " " THEN 9
  14. y5 = 1000
  15. y5 = y5 * 1000
  16.  
  17. COLOR 8, 0
  18. x1 = 143
  19. y1 = 74
  20. f = 0
  21. m = 2
  22. m1 = 1
  23. PRESET (7, 11) 'tank 2
  24. DRAW "c1 h2 u2 e2 r5u1e3r6f1 r10l10f3 r2f1r1f1r1f1r1d1g2l23"
  25. PAINT (18, 8), 1, 1
  26. LINE (12, 4)-(24, 4), 0
  27. FOR w = 7 TO 33 STEP 4
  28.     CIRCLE (w, 9), 1, 0
  29. NEXT 'tank 2
  30. GET (0, 0)-(33, 11), t()
  31. CLS
  32. PRESET (6, 9)
  33. DRAW "c3u3l1r2u1d1r2l1d3u2l1"
  34. GET (100, 100)-(136, 136), B()
  35. PRESET (105, 117)
  36. DRAW "c1r24l12u12d24u5c0u14d7l7r14"
  37. GET (100, 100)-(134, 134), e()
  38. GET (0, 0)-(14, 14), a()
  39.  
  40. CLS
  41. PRESET (5, 10) 'jeep
  42. DRAW "c1u5r1d5u3r3u5l1h1r1u1r4d1r3u1d2u1r2u1d2u1r2u1d2u1r2l9d1l2dd5r2f2r4u5d1r6f1d1f1d2l1u2d3l1h2l1g2d1f2r1e2g2l1h2u1l6h2l1g2d1f2r1e3g3l1h3u3"
  43. PAINT (10, 1), 1, 1
  44. PAINT (16, 11), 1, 1
  45. PSET (22, 8), 2
  46. GET (0, 0)-(26, 15), m() 'jeep
  47. CLS
  48. PRESET (28, 18)
  49. DRAW "c1r10l5u5d10u4c0l1u2r2d1"
  50. CIRCLE (33, 18), 7, 1, , , 1
  51. GET (15, 0)-(51, 36), c()
  52. CLS
  53.  
  54. FOR t = 0 TO 240 STEP 80 'The town
  55.     RESTORE
  56.     FOR i = t TO t + 79
  57.         READ j1
  58.         LINE (i, 65)-(i, 65 - j1), 2
  59. NEXT i, t
  60. LINE (0, 66)-(319, 75), 2, BF
  61. PAINT (160, 7), 1, 2
  62.  
  63. PRESET (5, 2)
  64. DRAW "c2 r4f3r10u1e2r2u2l10r20l9d2r1f4d2g2f2h2l7g2e2h2u2l12h3"
  65. PAINT (27, 8), 2, 2
  66. PAINT (9, 4), 2, 2
  67. PSET (9, 4), 3
  68. PRESET (28, 3)
  69. DRAW "c3d2r2h1"
  70. GET (5, 0)-(36, 12), z() 'helicopter
  71.  
  72. LINE (0, 0)-(36, 12), 1, BF
  73. CIRCLE (255, 17), 7, 3, , , .93: PAINT (255, 17), 3
  74. LINE (0, 20)-(40, 32), 1, BF
  75. LINE (0, 0)-(319, 199), , B
  76. GET (0, 0)-(319, 80), w()
  77.  
  78. FOR x = 3 TO 318 STEP 2.5 'The bridge
  79.     LINE (x, 99)-(x - 2, 98), 1
  80. NEXT
  81.  
  82. FOR i = 100 TO 106
  83.     LINE (0, i)-(319, i), 1, , &HAAAA
  84. NEXT
  85.  
  86. PRESET (25, 115) '‚®«*л
  87. DRAW "c1r2e2u1d1f1"
  88. GET (25, 112)-(30, 115), v()
  89. FOR i = 14 TO 300 STEP 6
  90.     PUT (i, 112), v(), PSET
  91. NEXT '‚®«*л
  92.  
  93. FOR g = 0 TO 10 STEP 2
  94.     LINE (g, 107)-(g, 116), 1
  95. NEXT
  96. FOR g = 308 TO 318 STEP 2
  97.     LINE (g, 107)-(g, 116), 1
  98. NEXT
  99. h = 8
  100. FOR g = 12 TO 28 STEP 2
  101.     LINE (g, 107)-(g, 107 + h), 1
  102.     h = h - 1
  103. NEXT
  104. h = h + 1
  105. FOR g = 290 TO 306 STEP 2
  106.     LINE (g, 107)-(g, 107 + h), 1
  107.     h = h + 1
  108. NEXT
  109. GET (0, 98)-(319, 116), w1() 'The bridge
  110. 1
  111.  
  112. f = 0
  113. x = INT(RND(1) * 243) + 20
  114. y = INT(RND(1) * 21) + 127
  115. v2 = 1
  116. LINE (138, 195)-(150, 184), , B: LINE (167, 195)-(179, 184), , B
  117. 2
  118. LINE (110, 198)-(134, 174)
  119. LINE (210, 198)-(186, 174)
  120. LINE (134, 174)-(186, 174)
  121.  
  122. 'FOR r5 = 0 TO y5: NEXT 'compensation of speed
  123.  
  124. IF j = 1 THEN LINE (139, 194)-(149, 185), 2, BF ELSE LINE (139, 194)-(149, 185), 0, BF
  125. IF m5 = 1 THEN LINE (168, 194)-(178, 185), 2, BF ELSE LINE (168, 194)-(178, 185), 0, BF
  126. PUT (0, 0), w(), PSET
  127. PUT (0, 98), w1(), PSET
  128. LOCATE 23, 19: PRINT v
  129.  
  130. IF m < 283 THEN PUT (m, 32), z(), PSET: m = m + 6 ELSE m = 1
  131. IF m1 < 299 AND v3 <> v2 THEN PUT (m1, 82), m(), PSET: m1 = m1 + 5
  132. IF v3 = v2 AND m1 < 283 THEN PUT (m1, 86), t(), PSET: m1 = m1 + 5
  133. IF m1 > 285 AND v2 = v3 THEN m1 = 1: LINE (m1, 82)-(318, 97), 0, BF: v1 = v1 + 1: v2 = INT(v1 / 3): v3 = v1 / 3
  134. IF m1 > 292 AND v2 <> v3 THEN m1 = 1: LINE (m1, 82)-(318, 97), 0, BF: v1 = v1 + 1: v2 = INT(v1 / 3): v3 = v1 / 3
  135.  
  136. IF a$ = "9" THEN m5 = 1
  137. IF a$ = "0" THEN m5 = 0: j = 0: f = 0: LINE (1, 117)-(318, 173), 0, BF
  138. IF a$ = "1" THEN m5 = 1: j = 1: f = 1
  139. IF x1 < 0 THEN x1 = x1 + 11
  140. IF x1 > 283 THEN x1 = x1 - 11
  141. IF y1 < 11 THEN y1 = y1 + 11
  142. IF y1 > 148 THEN y1 = y1 - 11
  143. IF f = 0 THEN
  144.     PUT (x1, y1), c(), XOR  'the cross-sight
  145.  
  146. startTime# = TIMER ' Calculate speed of system
  147. 'PRINT startTime#
  148. FOR i# = 1 TO 5000000: NEXT i# ' and do some compensation
  149. stopTime# = TIMER
  150. 'PRINT stopTime#
  151. speed = speed * .5 / (stopTime# - startTime#)
  152. curSpeed = speed 'Delay game
  153. FOR a# = 1 TO curSpeed: NEXT a#
  154.  
  155.     PUT (x1, y1), c(), XOR
  156. END IF
  157.  
  158. x = x + x2
  159. y = y + y2
  160. IF x < 20 THEN x = x + 5
  161. IF x > 263 THEN x = x - 5
  162. IF y < 127 THEN y = y + 5
  163. IF y > 148 THEN y = y - 5
  164. PUT (x, y), a(), PSET
  165. x9 = x1 + 18
  166. y9 = y1 + 18
  167.  
  168. 'LOCATE 15, 1: PRINT "27"; y1 + 18; "45"
  169. 'LOCATE 23, 4: PRINT m - 7; x1 + 18; m + 26 'Џа®ўҐаЄ*
  170. 'PSET (m - 7, 21), 3
  171. 'PSET (m + 26, 21), 3
  172.  
  173. IF m - 7 < x1 + 18 AND x1 + 18 < m + 26 AND y1 + 18 > 27 AND y1 + 18 < 45 AND a$ = " " THEN m = 283: v = v + 10
  174. IF v2 <> v3 THEN IF x1 > m1 - 20 AND x1 < m1 + 2 AND y1 > 63 AND y1 < 79 AND a$ = " " THEN m1 = 1: v = v + 10: LINE (1, 82)-(318, 97), 0, BF: v1 = v1 + 1: v3 = v1 / 3: v2 = INT(v1 / 3)
  175. IF v2 = v3 THEN IF x1 > m1 - 20 AND x1 < m1 + 10 AND y1 > 63 AND y1 < 79 AND a$ = " " THEN m4 = m4 + 1: IF m4 = 3 THEN m4 = 0: m1 = 1: v = v + 15: LINE (1, 82)-(318, 97), 0, BF: v1 = v1 + 1: v3 = v1 / 3: v2 = INT(v1 / 3)
  176. a$ = INKEY$
  177. a = INT(RND(1) * 20)
  178. IF a = 0 THEN x2 = 5: y2 = 0
  179. IF a = 1 THEN x2 = -5: y2 = 0
  180. IF a = 2 THEN y2 = 5: x2 = 0
  181. IF a = 3 THEN y2 = -5: x2 = 0
  182. IF a = 4 THEN x2 = -5: y2 = -5
  183. IF a = 5 THEN x2 = 5: y2 = -5
  184. IF a = 6 THEN x2 = 5: y2 = 5
  185. IF a = 7 THEN x2 = -5: y2 = 5
  186. IF a$ = "6" THEN x1 = x1 + 11
  187. IF a$ = "2" THEN y1 = y1 + 11
  188. IF a$ = "4" THEN x1 = x1 - 11
  189. IF a$ = "8" THEN y1 = y1 - 11
  190. IF a$ = "q" OR a$ = "Q" OR a$ = "©" OR a$ = "‰" THEN END '‚л室
  191.  
  192. IF m5 = 1 AND x > x1 - 13 AND x < x1 + 35 AND y > y1 - 13 AND y < y1 + 35 THEN f = 1: LINE (1, 117)-(318, 173), 0, BF
  193. IF f = 1 THEN LINE (1, 117)-(318, 173), 0, BF: PUT (x - 10, y - 10), e(), PSET: x1 = x: y1 = y
  194. IF j = 1 AND f = 1 THEN a$ = " "
  195. IF a$ = " " THEN LINE (1, 198)-(x1 + 18, y1 + 18), 3: LINE (318, 198)-(x1 + 18, y1 + 18), 3: LINE (1, 198)-(x1 + 18, y1 + 18), 0: LINE (318, 198)-(x1 + 18, y1 + 18), 0
  196. IF v > 745 THEN CLS: OUT 985, 10: LOCATE 11, 11: PRINT "-  congratulation  -": PLAY "g7e7c7e7d3    c5e7g7f3g7e7c7d7c3": PLAY "E6F6C6E6F6C3E3F6E6C7E7D3 ": END
  197. IF a$ = " " OR a$ = "5" THEN GOSUB 3
  198.  
  199. GOTO 2
  200. 3
  201. IF f = 1 THEN x1 = x - 11: y1 = y - 11: y = y1 + 3: x = x1 + 19
  202. IF x > x1 + 2 AND x < x1 + 20 AND y > y1 + 2 AND y < y1 + 20 THEN LINE (1, 117)-(318, 173), 0, BF: v = v + 1: GOTO 1
  203. RETURN

Объяснение кода листинга программы

This code is written in QBasic and seems to be a game. It contains a lot of game logic, including moving objects, drawing bridges, and handling user input. The speed of the game is controlled by a variable called speed, which is reduced by half every time the game is played. The code also includes a number of timers and delays, which are used to compensate for the speed of the system and ensure that the game runs at a consistent speed. There are a number of objects in the game, including a helicopter and a cross-hair, which move around the screen. The movement of these objects is controlled by variables such as x1, y1, x2, and y2, which are updated each time the game is played. The game also includes a number of conditions and if statements, which are used to handle collisions and other events in the game. Overall, this code seems to be a fairly complex game with a lot of moving parts and game logic. It would take some time and effort to fully understand and optimize the code for a specific purpose.

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

6   голосов , оценка 4.833 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы