Advertisement
BLUSHIF

Untitled

Nov 24th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.77 KB | None | 0 0
  1. "use strict";
  2. //begin jakechanges
  3. var clevel=1;
  4. var template;
  5. var ldata;
  6. var request = new XMLHttpRequest();
  7. request.open('GET', 'lt.txt', true);
  8. request.onload = function() {
  9. if (request.status >= 200 && request.status < 400) {
  10. template = request.responseText;
  11. } else throw"target server error loading template data";
  12. };
  13. request.onerror = function() {
  14. console.log("error loading template");
  15. };
  16. request.send();
  17. var request = new XMLHttpRequest();
  18. request.open('GET', clevel+'.txt', true);
  19. request.onload = function() {
  20. if (request.status >= 200 && request.status < 400) {
  21. ldata = request.responseText;
  22. } else throw"target server error";
  23. };
  24. request.onerror = function() {
  25. console.log("error loading level");
  26. };
  27. request.send();
  28. //end jakechanges
  29. var jc=template+ldata;
  30. (function()
  31. {
  32. function spawnSpike(game)
  33. {
  34. if(this.spike && this.spike.timer)
  35. {
  36. // there is already a spike that is moving
  37. return;
  38. }
  39.  
  40. this.spike = game.addObject({
  41. image: "spikeUp",
  42. killing: true,
  43. x: this.x,
  44. y: this.y,
  45. tickFunction: moveHiddenSpike,
  46. zIndex: -1,
  47. });
  48.  
  49. this.spike.timer = 64;
  50. }
  51.  
  52. function moveHiddenSpike(game)
  53. {
  54. if(this.timer)
  55. {
  56. this.y += Math.rectangle(64)(this.timer);
  57. this.timer--;
  58. }
  59. else
  60. {
  61. game.removeObject(this);
  62. }
  63. }
  64.  
  65. function startObject(id)
  66. {
  67. return function(game)
  68. {
  69. var obj = game.objectMap[id];
  70.  
  71. obj.active = true;
  72. obj.timer = 0;
  73.  
  74. // remove the trigger
  75. game.removeObject(this);
  76. }
  77. }
  78.  
  79. function movePlatform(game)
  80. {
  81. if(this.active)
  82. {
  83. if(this.timer % 2 === 0)
  84. {
  85. game.moveObjectDown(this, -1);
  86. }
  87.  
  88. if(this.y > 400)
  89. {
  90. game.moveObjectRight(this, -Math.rectangle(260)(this.timer + 65));
  91. }
  92. else
  93. {
  94. game.moveObjectRight(this, 1);
  95. }
  96.  
  97. if(this.x < -40)
  98. {
  99. game.removeObject(this);
  100. }
  101.  
  102. this.timer++;
  103. }
  104. }
  105.  
  106. function movePlatform2(game)
  107. {
  108. if(this.active)
  109. {
  110. if(this.timer < 95)
  111. {
  112. game.moveObjectRight(this, -2);
  113. }
  114. else if(this.timer < 185)
  115. {
  116. //game.moveObjectDown(this,
  117. // 2 * Math.rectangle(85)(this.timer - 95));
  118.  
  119. game.moveObjectRight(this, 3);
  120. }
  121. else if(this.timer < 325)
  122. {
  123. if(this.timer % 2)
  124. {
  125. game.moveObjectDown(this, -1);
  126. game.moveObjectRight(this, -1);
  127. }
  128. }
  129. else if(this.timer < 480)
  130. {
  131. game.moveObjectRight(this, -2);
  132. }
  133. else if(this.timer < 500)
  134. {
  135. game.moveObjectDown(this, 6);
  136. }
  137. else if(this.timer < 600)
  138. {
  139. game.moveObjectDown(this, -1);
  140. game.moveObjectRight(this,
  141. Math.round(2 * Math.triangle(80)(this.timer)));
  142. }
  143. else if(this.timer < 750)
  144. {
  145. game.moveObjectRight(this, -1);
  146. }
  147. else if(this.timer < 790)
  148. {
  149. game.moveObjectDown(this, -1);
  150. }
  151. else if(this.timer < 850)
  152. {
  153.  
  154. }
  155. else if(this.timer < 950)
  156. {
  157. game.moveObjectRight(this, 3);
  158. }
  159. else if(this.timer < 1000)
  160. {
  161. game.moveObjectDown(this, -1);
  162. }
  163. else if(this.timer < 1022)
  164. {
  165. game.moveObjectRight(this, 4);
  166. }
  167. else if(this.timer < 1050)
  168. {
  169.  
  170. }
  171. else if(this.timer < 1150)
  172. {
  173. game.moveObjectDown(this, -1);
  174. }
  175. else if(this.timer < 1230)
  176. {
  177. game.moveObjectRight(this, 1);
  178. }
  179. else if(this.timer < 1300)
  180. {
  181.  
  182. }
  183. else
  184. {
  185. game.moveObjectRight(this, -Math.ceil((this.timer - 1300) / 18));
  186. }
  187.  
  188.  
  189. this.timer++;
  190. }
  191. }
  192.  
  193. function badPlatform(game)
  194. {
  195. game.removeObject(this);
  196.  
  197. }
  198.  
  199. function transitionUp(game)
  200. {
  201. if(game.viewportY === 600)
  202. {
  203. game.viewportY = 0;
  204. }
  205. }
  206.  
  207. function transitionDown(game)
  208. {
  209. if(game.viewportY === 0)
  210. {
  211. game.viewportY = 600;
  212. }
  213. }
  214.  
  215. function additionalJump(game)
  216. {
  217. game.canJump = true;
  218. game.removeObject(this);
  219.  
  220. game.audio.play("Mega_Man_Blast_Sound.ogg");
  221. }
  222.  
  223.  
  224. function moveApple(game)
  225. {
  226. this.y += Math.rectangle(100)(game.tickCount);
  227. }
  228.  
  229. function redOrb(game)
  230. {
  231. var f = game.addObject({
  232. tickFunction: shake,
  233. });
  234.  
  235. f.timer = 0;
  236.  
  237. game.removeObject(this);
  238. }
  239.  
  240. function shake(game)
  241. {
  242. if(this.timer % 4 === 2)
  243. {
  244. game.viewportY -= 2;
  245. }
  246. else if(this.timer % 4 === 0)
  247. {
  248. game.viewportY += 2;
  249. }
  250.  
  251. if(this.timer % 10 === 0)
  252. {
  253. game.objectMap["exitBlock"].y--;
  254. game.objectMap["exitSpike"].y--;
  255. }
  256.  
  257. this.timer++;
  258.  
  259. if(this.timer > 1500)
  260. {
  261. game.removeObject(this);
  262. }
  263. }
  264.  
  265.  
  266. function tickFunction(game)
  267. {
  268. }
  269.  
  270. function nextLevel(game)
  271. {
  272. game.nextLevel("2up.js");
  273. //DOIT: CHANGE THIS METHOD TO RELOAD CSV RATHER THAN NEW LEVEL
  274. game.removeObject(this);
  275. }
  276.  
  277. function loadState(game, state)
  278. {
  279. if(state === 0xbeeeef)
  280. {
  281. game.posY = 224;
  282. game.posX = 37;
  283. game.viewportY = 0;
  284.  
  285. game.removeObjectById("saveState1");
  286. }
  287. else
  288. {
  289. console.log("invalid state: " + state);
  290. }
  291. }
  292.  
  293. function saveState1(game)
  294. {
  295. game.saveState(0xbeeeef);
  296. game.removeObject(this);
  297.  
  298. game.audio.play("Mega_Man_Beam_Sound.ogg", false, false);
  299. }
  300. return jc;
  301. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement