Guest User

Untitled

a guest
Feb 8th, 2022
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.39 KB | None | 0 0
  1. // vars
  2. var G, A, state, colstate
  3. // motion vectors
  4. var yPos = 0;
  5. var xPos = 0;
  6. var xVel = 0;
  7. var yVel = 0;
  8. //max velocity
  9. var mv = 10
  10. // check tile switch
  11. var checkx1 = true;
  12. var checky1 = true;
  13. var checkx2 = true;
  14. var checky2 = true;
  15. var checkx3 = true;
  16. var checky3 = true;
  17. var checkx4 = true;
  18. var checky4 = true;
  19. // tile array
  20. var tile1, tile2, tile3, tile4, tilex1, tiley1, tilex2, tiley2, tilex3, tiley3, tilex4, tiley4
  21. // ping
  22. var p = "PING"
  23. // Key
  24. var key = {};
  25. // Key input - Key[KEYCODE] == true/false
  26. window.onkeyup = function(e) { key[e.keyCode] = false; }
  27. window.onkeydown = function(e) { key[e.keyCode] = true; }
  28. // right ground acceleration
  29. function speedupx0() {
  30. xVel = xVel + 1;
  31. }
  32. // right air acceleration
  33. function speedupx1() {
  34. xVel = xVel + 0.75;
  35. }
  36. // left ground acceleration
  37. function speedupx2() {
  38. xVel = xVel - 1;
  39. }
  40.  
  41. // left air acceleration
  42. function speedupx3() {
  43. xVel = xVel - 0.75;
  44. }
  45. function checkxt1() {
  46. if (checkx1 == true) {
  47. if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 1) {
  48. tilex1 = "1";
  49. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 2) {
  50. tilex1 = "2";
  51. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 3) {
  52. tilex1 = "3";
  53. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 4) {
  54. tilex1 = "4";
  55. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 5) {
  56. tilex1 = "5";
  57. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 6) {
  58. tilex1 = "6";
  59. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 7) {
  60. tilex1 = "7";
  61. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 8) {
  62. tilex1 = "8";
  63. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 9) {
  64. tilex1 = "9";
  65. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 10) {
  66. tilex1 = "10";
  67. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 11) {
  68. tilex1 = "11";
  69. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 12) {
  70. tilex1 = "12";
  71. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 13) {
  72. tilex1 = "13";
  73. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 14) {
  74. tilex1 = "14";
  75. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 15) {
  76. tilex1 = "15";
  77. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 16) {
  78. tilex1 = "16";
  79. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 17) {
  80. tilex1 = "17";
  81. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 18) {
  82. tilex1 = "18";
  83. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 19) {
  84. tilex1 = "19";
  85. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 20) {
  86. tilex1 = "20";
  87. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 21) {
  88. tilex1 = "21";
  89. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 22) {
  90. tilex1 = "22";
  91. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 23) {
  92. tilex1 = "23";
  93. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 24) {
  94. tilex1 = "24";
  95. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 25) {
  96. tilex1 = "25";
  97. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 26) {
  98. tilex1 = "26";
  99. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 27) {
  100. tilex1 = "27";
  101. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 28) {
  102. tilex1 = "28";
  103. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 29) {
  104. tilex1 = "29";
  105. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 30) {
  106. tilex1 = "30";
  107. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 31) {
  108. tilex1 = "31";
  109. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 32) {
  110. tilex1 = "32";
  111. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 33) {
  112. tilex1 = "33";
  113. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 34) {
  114. tilex1 = "34";
  115. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 35) {
  116. tilex1 = "35";
  117. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 36) {
  118. tilex1 = "36";
  119. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 37) {
  120. tilex1 = "37";
  121. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 38) {
  122. tilex1 = "38";
  123. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 39) {
  124. tilex1 = "39";
  125. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 40) {
  126. tilex1 = "40";
  127. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 41) {
  128. tilex1 = "41";
  129. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 42) {
  130. tilex1 = "42";
  131. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 43) {
  132. tilex1 = "43";
  133. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 44) {
  134. tilex1 = "44";
  135. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 45) {
  136. tilex1 = "45";
  137. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 46) {
  138. tilex1 = "46";
  139. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 47) {
  140. tilex1 = "47";
  141. } else if (xPos + (innerWidth * 0.0365625) <= innerWidth) {
  142. tilex1 = "48";
  143. };
  144. };
  145. };
  146. function checkyt1() {
  147. if (checky1 == true) {
  148. if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 1) {
  149. tiley1 = "A";
  150. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 2) {
  151. tiley1 = "B";
  152. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 3) {
  153. tiley1 = "C";
  154. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 4) {
  155. tiley1 = "D";
  156. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 5) {
  157. tiley1 = "E";
  158. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 6) {
  159. tiley1 = "F";
  160. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 7) {
  161. tiley1 = "G";
  162. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 8) {
  163. tiley1 = "H";
  164. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 9) {
  165. tiley1 = "I";
  166. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 10) {
  167. tiley1 = "J";
  168. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 11) {
  169. tiley1 = "K";
  170. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 12) {
  171. tiley1 = "L";
  172. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 13) {
  173. tiley1 = "M";
  174. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 14) {
  175. tiley1 = "N";
  176. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 15) {
  177. tiley1 = "O";
  178. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 16) {
  179. tiley1 = "P";
  180. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 17) {
  181. tiley1 = "Q";
  182. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 18) {
  183. tiley1 = "R";
  184. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 19) {
  185. tiley1 = "S";
  186. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 20) {
  187. tiley1 = "T";
  188. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 21) {
  189. tiley1 = "U";
  190. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 22) {
  191. tiley1 = "V";
  192. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 23) {
  193. tiley1 = "W";
  194. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 24) {
  195. tiley1 = "X";
  196. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 25) {
  197. tiley1 = "Y";
  198. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 26) {
  199. tiley1 = "Z";
  200. } else if (yPos + (innerHeight * 0.065) <= innerHeight / 27) {
  201. tiley1 = "0";
  202. };
  203. };
  204. };
  205. function checkxt2() {
  206. if (checkx2 == true) {
  207. if (xPos <= (innerWidth / 48) * 1) {
  208. tilex2 = "1";
  209. } else if (xPos <= (innerWidth / 48) * 2) {
  210. tilex2 = "2";
  211. } else if (xPos <= (innerWidth / 48) * 3) {
  212. tilex2 = "3";
  213. } else if (xPos <= (innerWidth / 48) * 4) {
  214. tilex2 = "4";
  215. } else if (xPos <= (innerWidth / 48) * 5) {
  216. tilex2 = "5";
  217. } else if (xPos <= (innerWidth / 48) * 6) {
  218. tilex2 = "6";
  219. } else if (xPos <= (innerWidth / 48) * 7) {
  220. tilex2 = "7";
  221. } else if (xPos <= (innerWidth / 48) * 8) {
  222. tilex2 = "8";
  223. } else if (xPos <= (innerWidth / 48) * 9) {
  224. tilex2 = "9";
  225. } else if (xPos <= (innerWidth / 48) * 10) {
  226. tilex2 = "10";
  227. } else if (xPos <= (innerWidth / 48) * 11) {
  228. tilex2 = "11";
  229. } else if (xPos <= (innerWidth / 48) * 12) {
  230. tilex2 = "12";
  231. } else if (xPos <= (innerWidth / 48) * 13) {
  232. tilex2 = "13";
  233. } else if (xPos <= (innerWidth / 48) * 14) {
  234. tilex2 = "14";
  235. } else if (xPos <= (innerWidth / 48) * 15) {
  236. tilex2 = "15";
  237. } else if (xPos <= (innerWidth / 48) * 16) {
  238. tilex2 = "16";
  239. } else if (xPos <= (innerWidth / 48) * 17) {
  240. tilex2 = "17";
  241. } else if (xPos <= (innerWidth / 48) * 18) {
  242. tilex2 = "18";
  243. } else if (xPos <= (innerWidth / 48) * 19) {
  244. tilex2 = "19";
  245. } else if (xPos <= (innerWidth / 48) * 20) {
  246. tilex2 = "20";
  247. } else if (xPos <= (innerWidth / 48) * 21) {
  248. tilex2 = "21";
  249. } else if (xPos <= (innerWidth / 48) * 22) {
  250. tilex2 = "22";
  251. } else if (xPos <= (innerWidth / 48) * 23) {
  252. tilex2 = "23";
  253. } else if (xPos <= (innerWidth / 48) * 24) {
  254. tilex2 = "24";
  255. } else if (xPos <= (innerWidth / 48) * 25) {
  256. tilex2 = "25";
  257. } else if (xPos <= (innerWidth / 48) * 26) {
  258. tilex2 = "26";
  259. } else if (xPos <= (innerWidth / 48) * 27) {
  260. tilex2 = "27";
  261. } else if (xPos <= (innerWidth / 48) * 28) {
  262. tilex2 = "28";
  263. } else if (xPos <= (innerWidth / 48) * 29) {
  264. tilex2 = "29";
  265. } else if (xPos <= (innerWidth / 48) * 30) {
  266. tilex2 = "30";
  267. } else if (xPos <= (innerWidth / 48) * 31) {
  268. tilex2 = "31";
  269. } else if (xPos <= (innerWidth / 48) * 32) {
  270. tilex2 = "32";
  271. } else if (xPos <= (innerWidth / 48) * 33) {
  272. tilex2 = "33";
  273. } else if (xPos <= (innerWidth / 48) * 34) {
  274. tilex2 = "34";
  275. } else if (xPos <= (innerWidth / 48) * 35) {
  276. tilex2 = "35";
  277. } else if (xPos <= (innerWidth / 48) * 36) {
  278. tilex2 = "36";
  279. } else if (xPos <= (innerWidth / 48) * 37) {
  280. tilex2 = "37";
  281. } else if (xPos <= (innerWidth / 48) * 38) {
  282. tilex2 = "38";
  283. } else if (xPos <= (innerWidth / 48) * 39) {
  284. tilex2 = "39";
  285. } else if (xPos <= (innerWidth / 48) * 40) {
  286. tilex2 = "40";
  287. } else if (xPos <= (innerWidth / 48) * 41) {
  288. tilex2 = "41";
  289. } else if (xPos <= (innerWidth / 48) * 42) {
  290. tilex2 = "42";
  291. } else if (xPos <= (innerWidth / 48) * 43) {
  292. tilex2 = "43";
  293. } else if (xPos <= (innerWidth / 48) * 44) {
  294. tilex2 = "44";
  295. } else if (xPos <= (innerWidth / 48) * 45) {
  296. tilex2 = "45";
  297. } else if (xPos <= (innerWidth / 48) * 46) {
  298. tilex2 = "46";
  299. } else if (xPos <= (innerWidth / 48) * 47) {
  300. tilex2 = "47";
  301. } else if (xPos <= innerWidth) {
  302. tilex2 = "48";
  303. };
  304. };
  305. };
  306. function checkyt2() {
  307. if (checky2 == true) {
  308. if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 1) {
  309. tiley2 = "A";
  310. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 2) {
  311. tiley2 = "B";
  312. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 3) {
  313. tiley2 = "C";
  314. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 4) {
  315. tiley2 = "D";
  316. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 5) {
  317. tiley2 = "E";
  318. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 6) {
  319. tiley2 = "F";
  320. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 7) {
  321. tiley2 = "G";
  322. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 8) {
  323. tiley2 = "H";
  324. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 9) {
  325. tiley2 = "I";
  326. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 10) {
  327. tiley2 = "J";
  328. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 11) {
  329. tiley2 = "K";
  330. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 12) {
  331. tiley2 = "L";
  332. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 13) {
  333. tiley2 = "M";
  334. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 14) {
  335. tiley2 = "N";
  336. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 15) {
  337. tiley2 = "O";
  338. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 16) {
  339. tiley2 = "P";
  340. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 17) {
  341. tiley2 = "Q";
  342. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 18) {
  343. tiley2 = "R";
  344. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 19) {
  345. tiley2 = "S";
  346. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 20) {
  347. tiley2 = "T";
  348. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 21) {
  349. tiley2 = "U";
  350. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 22) {
  351. tiley2 = "V";
  352. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 23) {
  353. tiley2 = "W";
  354. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 24) {
  355. tiley2 = "X";
  356. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 25) {
  357. tiley2 = "Y";
  358. } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 26) {
  359. tiley2 = "Z";
  360. } else if (yPos + (innerHeight * 0.065) <= innerHeight / 27) {
  361. tiley1 = "0";
  362. };
  363. };
  364. };
  365. function checkxt3() {
  366. if (checkx3 == true) {
  367. if (xPos <= (innerWidth / 48) * 1) {
  368. tilex3 = "1";
  369. } else if (xPos <= (innerWidth / 48) * 2) {
  370. tilex3 = "2";
  371. } else if (xPos <= (innerWidth / 48) * 3) {
  372. tilex3 = "3";
  373. } else if (xPos <= (innerWidth / 48) * 4) {
  374. tilex3 = "4";
  375. } else if (xPos <= (innerWidth / 48) * 5) {
  376. tilex3 = "5";
  377. } else if (xPos <= (innerWidth / 48) * 6) {
  378. tilex3 = "6";
  379. } else if (xPos <= (innerWidth / 48) * 7) {
  380. tilex3 = "7";
  381. } else if (xPos <= (innerWidth / 48) * 8) {
  382. tilex3 = "8";
  383. } else if (xPos <= (innerWidth / 48) * 9) {
  384. tilex3 = "9";
  385. } else if (xPos <= (innerWidth / 48) * 10) {
  386. tilex3 = "10";
  387. } else if (xPos <= (innerWidth / 48) * 11) {
  388. tilex3 = "11";
  389. } else if (xPos <= (innerWidth / 48) * 12) {
  390. tilex3 = "12";
  391. } else if (xPos <= (innerWidth / 48) * 13) {
  392. tilex3 = "13";
  393. } else if (xPos <= (innerWidth / 48) * 14) {
  394. tilex3 = "14";
  395. } else if (xPos <= (innerWidth / 48) * 15) {
  396. tilex3 = "15";
  397. } else if (xPos <= (innerWidth / 48) * 16) {
  398. tilex3 = "16";
  399. } else if (xPos <= (innerWidth / 48) * 17) {
  400. tilex3 = "17";
  401. } else if (xPos <= (innerWidth / 48) * 18) {
  402. tilex3 = "18";
  403. } else if (xPos <= (innerWidth / 48) * 19) {
  404. tilex3 = "19";
  405. } else if (xPos <= (innerWidth / 48) * 20) {
  406. tilex3 = "20";
  407. } else if (xPos <= (innerWidth / 48) * 21) {
  408. tilex3 = "21";
  409. } else if (xPos <= (innerWidth / 48) * 22) {
  410. tilex3 = "22";
  411. } else if (xPos <= (innerWidth / 48) * 23) {
  412. tilex3 = "23";
  413. } else if (xPos <= (innerWidth / 48) * 24) {
  414. tilex3 = "24";
  415. } else if (xPos <= (innerWidth / 48) * 25) {
  416. tilex3 = "25";
  417. } else if (xPos <= (innerWidth / 48) * 26) {
  418. tilex3 = "26";
  419. } else if (xPos <= (innerWidth / 48) * 27) {
  420. tilex3 = "27";
  421. } else if (xPos <= (innerWidth / 48) * 28) {
  422. tilex3 = "28";
  423. } else if (xPos <= (innerWidth / 48) * 29) {
  424. tilex3 = "29";
  425. } else if (xPos <= (innerWidth / 48) * 30) {
  426. tilex3 = "30";
  427. } else if (xPos <= (innerWidth / 48) * 31) {
  428. tilex3 = "31";
  429. } else if (xPos <= (innerWidth / 48) * 32) {
  430. tilex3 = "32";
  431. } else if (xPos <= (innerWidth / 48) * 33) {
  432. tilex3 = "33";
  433. } else if (xPos <= (innerWidth / 48) * 34) {
  434. tilex3 = "34";
  435. } else if (xPos <= (innerWidth / 48) * 35) {
  436. tilex3 = "35";
  437. } else if (xPos <= (innerWidth / 48) * 36) {
  438. tilex3 = "36";
  439. } else if (xPos <= (innerWidth / 48) * 37) {
  440. tilex3 = "37";
  441. } else if (xPos <= (innerWidth / 48) * 38) {
  442. tilex3 = "38";
  443. } else if (xPos <= (innerWidth / 48) * 39) {
  444. tilex3 = "39";
  445. } else if (xPos <= (innerWidth / 48) * 40) {
  446. tilex3 = "40";
  447. } else if (xPos <= (innerWidth / 48) * 41) {
  448. tilex3 = "41";
  449. } else if (xPos <= (innerWidth / 48) * 42) {
  450. tilex3 = "42";
  451. } else if (xPos <= (innerWidth / 48) * 43) {
  452. tilex3 = "43";
  453. } else if (xPos <= (innerWidth / 48) * 44) {
  454. tilex3 = "44";
  455. } else if (xPos <= (innerWidth / 48) * 45) {
  456. tilex3 = "45";
  457. } else if (xPos <= (innerWidth / 48) * 46) {
  458. tilex3 = "46";
  459. } else if (xPos <= (innerWidth / 48) * 47) {
  460. tilex3 = "47";
  461. } else if (xPos <= innerWidth) {
  462. tilex3 = "48";
  463. };
  464. };
  465. };
  466. function checkyt3() {
  467. if (checky3 == true) {
  468. if (yPos <= (innerHeight / 27) * 1) {
  469. tiley3 = "A";
  470. } else if (yPos <= (innerHeight / 27) * 2) {
  471. tiley3 = "B";
  472. } else if (yPos <= (innerHeight / 27) * 3) {
  473. tiley3 = "C";
  474. } else if (yPos <= (innerHeight / 27) * 4) {
  475. tiley3 = "D";
  476. } else if (yPos <= (innerHeight / 27) * 5) {
  477. tiley3 = "E";
  478. } else if (yPos <= (innerHeight / 27) * 6) {
  479. tiley3 = "F";
  480. } else if (yPos <= (innerHeight / 27) * 7) {
  481. tiley3 = "G";
  482. } else if (yPos <= (innerHeight / 27) * 8) {
  483. tiley3 = "H";
  484. } else if (yPos <= (innerHeight / 27) * 9) {
  485. tiley3 = "I";
  486. } else if (yPos <= (innerHeight / 27) * 10) {
  487. tiley3 = "J";
  488. } else if (yPos <= (innerHeight / 27) * 11) {
  489. tiley3 = "K";
  490. } else if (yPos <= (innerHeight / 27) * 12) {
  491. tiley3 = "L";
  492. } else if (yPos <= (innerHeight / 27) * 13) {
  493. tiley3 = "M";
  494. } else if (yPos <= (innerHeight / 27) * 14) {
  495. tiley3 = "N";
  496. } else if (yPos <= (innerHeight / 27) * 15) {
  497. tiley3 = "O";
  498. } else if (yPos <= (innerHeight / 27) * 16) {
  499. tiley3 = "P";
  500. } else if (yPos <= (innerHeight / 27) * 17) {
  501. tiley3 = "Q";
  502. } else if (yPos <= (innerHeight / 27) * 18) {
  503. tiley3 = "R";
  504. } else if (yPos <= (innerHeight / 27) * 19) {
  505. tiley3 = "S";
  506. } else if (yPos <= (innerHeight / 27) * 20) {
  507. tiley3 = "T";
  508. } else if (yPos <= (innerHeight / 27) * 21) {
  509. tiley3 = "U";
  510. } else if (yPos <= (innerHeight / 27) * 22) {
  511. tiley3 = "V";
  512. } else if (yPos <= (innerHeight / 27) * 23) {
  513. tiley3 = "W";
  514. } else if (yPos <= (innerHeight / 27) * 24) {
  515. tiley3 = "X";
  516. } else if (yPos <= (innerHeight / 27) * 25) {
  517. tiley3 = "Y";
  518. } else if (yPos <= (innerHeight / 27) * 26) {
  519. tiley3 = "Z";
  520. } else if (yPos <= innerHeight / 27) {
  521. tiley3 = "0";
  522. };
  523. };
  524. };
  525. function checkxt4() {
  526. if (checkx4 == true) {
  527. if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 1) {
  528. tilex4 = "1";
  529. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 2) {
  530. tilex4 = "2";
  531. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 3) {
  532. tilex4 = "3";
  533. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 4) {
  534. tilex4 = "4";
  535. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 5) {
  536. tilex4 = "5";
  537. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 6) {
  538. tilex4 = "6";
  539. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 7) {
  540. tilex4 = "7";
  541. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 8) {
  542. tilex4 = "8";
  543. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 9) {
  544. tilex4 = "9";
  545. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 10) {
  546. tilex4 = "10";
  547. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 11) {
  548. tilex4 = "11";
  549. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 12) {
  550. tilex4 = "12";
  551. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 13) {
  552. tilex4 = "13";
  553. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 14) {
  554. tilex4 = "14";
  555. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 15) {
  556. tilex4 = "15";
  557. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 16) {
  558. tilex4 = "16";
  559. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 17) {
  560. tilex4 = "17";
  561. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 18) {
  562. tilex4 = "18";
  563. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 19) {
  564. tilex4 = "19";
  565. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 20) {
  566. tilex4 = "20";
  567. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 21) {
  568. tilex4 = "21";
  569. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 22) {
  570. tilex4 = "22";
  571. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 23) {
  572. tilex4 = "23";
  573. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 24) {
  574. tilex4 = "24";
  575. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 25) {
  576. tilex4 = "25";
  577. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 26) {
  578. tilex4 = "26";
  579. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 27) {
  580. tilex4 = "27";
  581. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 28) {
  582. tilex4 = "28";
  583. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 29) {
  584. tilex4 = "29";
  585. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 30) {
  586. tilex4 = "30";
  587. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 31) {
  588. tilex4 = "31";
  589. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 32) {
  590. tilex4 = "32";
  591. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 33) {
  592. tilex4 = "33";
  593. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 34) {
  594. tilex4 = "34";
  595. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 35) {
  596. tilex4 = "35";
  597. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 36) {
  598. tilex4 = "36";
  599. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 37) {
  600. tilex4 = "37";
  601. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 38) {
  602. tilex4 = "38";
  603. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 39) {
  604. tilex4 = "39";
  605. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 40) {
  606. tilex4 = "40";
  607. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 41) {
  608. tilex4 = "41";
  609. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 42) {
  610. tilex4 = "42";
  611. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 43) {
  612. tilex4 = "43";
  613. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 44) {
  614. tilex4 = "44";
  615. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 45) {
  616. tilex4 = "45";
  617. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 46) {
  618. tilex4 = "46";
  619. } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 47) {
  620. tilex4 = "47";
  621. } else if (xPos + (innerWidth * 0.0365625) <= innerWidth) {
  622. tilex4 = "48";
  623. };
  624. };
  625. };
  626. function checkyt4() {
  627. if (checky4 == true) {
  628. if (yPos <= (innerHeight / 27) * 1) {
  629. tiley4 = "A";
  630. } else if (yPos <= (innerHeight / 27) * 2) {
  631. tiley4 = "B";
  632. } else if (yPos <= (innerHeight / 27) * 3) {
  633. tiley4 = "C";
  634. } else if (yPos <= (innerHeight / 27) * 4) {
  635. tiley4 = "D";
  636. } else if (yPos <= (innerHeight / 27) * 5) {
  637. tiley4 = "E";
  638. } else if (yPos <= (innerHeight / 27) * 6) {
  639. tiley4 = "F";
  640. } else if (yPos <= (innerHeight / 27) * 7) {
  641. tiley4 = "G";
  642. } else if (yPos <= (innerHeight / 27) * 8) {
  643. tiley4 = "H";
  644. } else if (yPos <= (innerHeight / 27) * 9) {
  645. tiley4 = "I";
  646. } else if (yPos <= (innerHeight / 27) * 10) {
  647. tiley4 = "J";
  648. } else if (yPos <= (innerHeight / 27) * 11) {
  649. tiley4 = "K";
  650. } else if (yPos <= (innerHeight / 27) * 12) {
  651. tiley4 = "L";
  652. } else if (yPos <= (innerHeight / 27) * 13) {
  653. tiley4 = "M";
  654. } else if (yPos <= (innerHeight / 27) * 14) {
  655. tiley4 = "N";
  656. } else if (yPos <= (innerHeight / 27) * 15) {
  657. tiley4 = "O";
  658. } else if (yPos <= (innerHeight / 27) * 16) {
  659. tiley4 = "P";
  660. } else if (yPos <= (innerHeight / 27) * 17) {
  661. tiley4 = "Q";
  662. } else if (yPos <= (innerHeight / 27) * 18) {
  663. tiley4 = "R";
  664. } else if (yPos <= (innerHeight / 27) * 19) {
  665. tiley4 = "S";
  666. } else if (yPos <= (innerHeight / 27) * 20) {
  667. tiley4 = "T";
  668. } else if (yPos <= (innerHeight / 27) * 21) {
  669. tiley4 = "U";
  670. } else if (yPos <= (innerHeight / 27) * 22) {
  671. tiley4 = "V";
  672. } else if (yPos <= (innerHeight / 27) * 23) {
  673. tiley4 = "W";
  674. } else if (yPos <= (innerHeight / 27) * 24) {
  675. tiley4 = "X";
  676. } else if (yPos <= (innerHeight / 27) * 25) {
  677. tiley4 = "Y";
  678. } else if (yPos <= (innerHeight / 27) * 26) {
  679. tiley4 = "Z";
  680. } else if (yPos <= innerHeight / 27) {
  681. tiley4 = "0";
  682. };
  683. };
  684. };
  685. function roundgrav(x) {
  686. return Math.ceil(x / 10) * 10;
  687. }
  688. setInterval (function update() {
  689.  
  690. var sprite = document.getElementById('sprite');
  691. sprite.style.bottom = yPos + 'px';
  692. sprite.style.left = xPos + 'px';
  693. xPos = xPos + xVel;
  694. yPos = yPos + yVel;
  695. checkxt1();
  696. checkyt1();
  697. checkxt2();
  698. checkyt2();
  699. checkxt3();
  700. checkyt3();
  701. checkxt4();
  702. checkyt4();
  703. tile1 = tiley1 + tilex1;
  704. tile2 = tiley2 + tilex2;
  705. tile3 = tiley3 + tilex3;
  706. tile4 = tiley4 + tilex4;
  707. // console.log("1:",tile1,'\n',"2:",tile2,'\n',"3:",tile3,'\n',"4:",tile4)
  708. // TEMP ground
  709. if (yPos <= 0) {
  710. G = true;
  711. A = false;
  712. yPos = 0;
  713. } else if (colstate == 0) {
  714. G = false;
  715. A = true;
  716. };
  717. // gravity
  718. if (G == true) {
  719. yVel = 0;
  720. } else if (yVel >= -30) {
  721. yVel = yVel - 0.5;
  722. }
  723. // col
  724. if (tile3 == "D27" || tile3 == "D28" || tile3 == "D29" || tile3 == "D30" || tile4 == "D27" || tile4 == "D28" || tile4 == "D29" || tile4 == "D30" || tile3 == "H36" || tile3 == "H37" || tile3 == "H38" || tile3 == "H39" || tile4 == "H36" || tile4 == "H37" || tile4 == "H38" || tile4 == "H39" || tile3 == "L30" || tile3 == "L31" || tile3 == "L32" || tile3 == "L33" || tile4 == "L30" || tile4 == "L31" || tile4 == "L32" || tile4 == "L33" || tile3 == "L20" || tile3 == "L21" || tile3 == "L22" || tile3 == "L23" || tile4 == "L20" || tile4 == "L21" || tile4 == "L22" || tile4 == "L23") {
  725. yVel = 0;
  726. G = true;
  727. A = false;
  728. colstate = 1;
  729. } else {
  730. colstate = 0;
  731. }
  732. // friction
  733. if (G == true) {
  734. if (xVel > 0) {
  735. xVel = xVel - 0.5;
  736. } else if (xVel < 0) {
  737. xVel = xVel + 0.5;
  738. }
  739. } else {
  740. if (xVel > 0) {
  741. xVel = xVel - 0.25;
  742. } else if (xVel < 0) {
  743. xVel = xVel + 0.25;
  744. }
  745. }
  746. // impact - fix for air to ground friction deficit
  747. if (A == true) {
  748. state = 1;
  749. }
  750. if (state == 1) {
  751. if (G == true) {
  752. state = 0;
  753. xVel = Math.round(xVel)
  754. yPos = roundgrav(yPos)
  755. }
  756. }
  757. // jump
  758. if (key[32] == true && G == true) {
  759. if (yVel <= 13.5) {
  760. yVel = 13.5;
  761. }
  762. };
  763. // right
  764. if (key[68] == true) {
  765. if (G == true) {
  766. var reintxvg0 = setInterval(speedupx0(), 20)
  767. if (xVel > mv) {
  768. clearInterval(reintxvg0);
  769. xVel = mv
  770. };
  771. } else if (A == true) {
  772. var reintxvg1 = setInterval(speedupx1(), 20)
  773. if (xVel > mv) {
  774. clearInterval(reintxvg1);
  775. xVel = mv
  776. }
  777. }
  778. };
  779. // left
  780. if (key[65] == true) {
  781. if (G == true) {
  782. var reintxvg0 = setInterval(speedupx2(), 20)
  783. if (xVel < -mv) {
  784. clearInterval(reintxvg0);
  785. xVel = -mv
  786. };
  787. } else if (A == true) {
  788. var reintxvg1 = setInterval(speedupx3(), 20)
  789. if (xVel < -mv) {
  790. clearInterval(reintxvg1);
  791. xVel = -mv
  792. }
  793. }
  794. };
  795. // tile x
  796.  
  797.  
  798. }, 16.66);
  799.  
Advertisement
Add Comment
Please, Sign In to add comment