qqwref

Untitled

Apr 13th, 2020 (edited)
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.29 KB | None | 0 0
  1.  
  2. var green = color(144, 192, 84, 1);
  3. var brown = color(139, 69, 19, 1);
  4. var red = color(255, 0, 0, 1);
  5. var blue = color(53, 126, 215, 1);
  6. var cloudVision = 25;
  7.  
  8. platform3D(-50, -50, 0, 100, 100, 3, green);
  9.  
  10. // a white platform that has no shadow and only appears when you get near it
  11. function cloudPlatform(x, y, z, w, h, d, px, py, pz) {
  12. var distance = Math.sqrt(Math.pow(player.pos[0] - (x + w/2), 2) + Math.pow(player.pos[1] - (y + h/2), 2));
  13. box3D(x, y, z, w, h, d, color(255, 255, 255, Math.max(0, 1 - (distance/cloudVision))), 0);
  14. platforms.push([x, y, z, w, h, d, x-px, y-py, z-pz]);
  15. }
  16. function bobbingCloudPlatform(x, y, z, w, h, d, cycle, offset, amount, axis) {
  17. var a = [x, y, z][axis];
  18. var pa = a + Math.sin(((frameCount - 1) / 100) * cycle + offset) * amount;
  19. a += Math.sin((frameCount / 100) * cycle + offset) * amount;
  20. var ppos = [x, y, z];
  21. ppos[axis] = pa;
  22. var pos = [x, y, z];
  23. pos[axis] = a;
  24. var distance = Math.sqrt(Math.pow(player.pos[0] - (pos[0] + w/2), 2) + Math.pow(player.pos[1] - (pos[1] + h/2), 2));
  25. box3D(pos[0], pos[1], pos[2], w, h, d, color(255,255,255,Math.max(0, 1 - (distance/cloudVision))), 0);
  26. platforms.push([pos[0], pos[1], pos[2], w, h, d, pos[0]-ppos[0], pos[1]-ppos[1], pos[2]-ppos[2]]);
  27. }
  28.  
  29. // a purple platform that waps you to [wx,wy,wz] if you step on it
  30. function warpPlatform(x, y, z, w, h, d, wx, wy, wz) {
  31. platform3D(x, y, z, w, h, d, color(90, 0, 180, 1));
  32. if (player.pos[0] >= x && player.pos[0] <= x+w && player.pos[1] >= y && player.pos[1] <= y+h && Math.abs(player.pos[2] - (z-1)) <= 0.1) {
  33. player.pos = [wx, wy, wz];
  34. }
  35. }
  36.  
  37. // a springy platform that makes your jumps higher by a factor of factor
  38. function springPlatform(x, y, z, h, w, d, factor) {
  39. platform3D(x, y, z, w, h, d, color(255, 255, 90, 1));
  40. if (player.pos[0] >= x && player.pos[0] <= x+w && player.pos[1] >= y && player.pos[1] <= y+h && Math.abs(player.pos[2] - (z-1)) <= 0.1 &&
  41.  
  42. player.vel[2] <= 0) {
  43. player.vel[2] *= factor;
  44. }
  45. }
  46.  
  47. // fire wall platform: red, moves, and if you touch it, you die
  48. // make y-direction firewallin a bounding box, starting when you reach starty, stopping at the end
  49. function fireWall(bbx, bby, bbz, bbh, bbw, bbd, color, starty, speed) {
  50. if (window.fireWall_y == undefined) {
  51. window.fireWall_y = [];
  52. }
  53. if (window.fireWall_y[bby] != undefined) {
  54. window.fireWall_y[bby] += speed;
  55. if (window.fireWall_y[bby] > bby + bbw || player.pos[0] < bbx || player.pos[0] > bbx + bbh || player.pos[1] < bby || player.pos[1] > bby + bbw ||
  56.  
  57. player.pos[2] < bbz || player.pos[2] > bbz + bbd) {
  58. window.fireWall_y[bby] = undefined;
  59. } else {
  60. platform3D(bbx, window.fireWall_y[bby], bbz, bbh, 2, bbd, color);
  61. if (player.pos[1] < window.fireWall_y[bby]) {
  62. player.pos[2] = 10;
  63. window.fireWall_y[bby] = undefined;
  64. }
  65. }
  66. } else {
  67. if (player.pos[0] >= bbx && player.pos[0] <= bbx + bbh && player.pos[2] >= bbz && player.pos[2] <= bbz + bbd && player.pos[1] >= starty &&
  68.  
  69. player.pos[1] <= bby + bbw) {
  70. window.fireWall_y[bby] = bby;
  71. }
  72. }
  73. }
  74. // earth platform: brown, moves, and pushes you
  75. function pushMover(fx, fy, fz, h, w, d, color) {
  76. platform3D(fx(frameCount), fy(frameCount), fz(frameCount), h, w, d, color, fx(frameCount-1), fy(frameCount-1), fz(frameCount-1));
  77. }
  78. function triangleX(x, time, dist) {
  79. var z = x%(2*time);
  80. if (z < time) return z*(dist/time);
  81. return (2*time-z)*(dist/time);
  82. }
  83. // black platform that kills you if you touch it
  84. function deathPlatform(x, y, z, h, w, d) {
  85. box3D(x, y, z, h, w, d, color(0, 0, 0, 1), 0);
  86. if (player.pos[0] >= x && player.pos[0] <= x+h && player.pos[1] >= y && player.pos[1] <= y+w && player.pos[2] >= z && player.pos[2] <= z+d) {
  87. player.pos[2] = 10;
  88. }
  89. }
  90.  
  91. // air part 1
  92. cloudPlatform(60, -20, -3, 8, 8, 1);
  93. cloudPlatform(80, -15, -5, 3, 8, 1);
  94. cloudPlatform(90, 0, -5, 4, 5, 1);
  95. cloudPlatform(96, 0, -16, 14, 5, 1);
  96. cloudPlatform(104, -12, -21, 6, 5, 1);
  97. cloudPlatform(120, -26, -15, 6, 6, 1);
  98. cloudPlatform(135, -15, -19, 3, 8, 1);
  99. cloudPlatform(152, -15, -23, 3, 8, 1);
  100. cloudPlatform(155, -35, -23, 20, 3, 1);
  101. cloudPlatform(165, -35, -40, 8, 3, 6);
  102. bobbingCloudPlatform(165, -31, -60, 8, 8, 2, 5, 0, 20, 2);
  103. platform3D(183, -50, -80, 10, 30, 3, green);
  104.  
  105. // air part 2
  106. bobbingCloudPlatform(213, -40, -96, 10, 10, 10, 2, 0, 30, 0);
  107. cloudPlatform(243, -40, -80, 10, 10, 1, green);
  108. cloudPlatform(243, -28, -50, 6, 6, 1, green);
  109. cloudPlatform(265, -22, -53, 15, 3, 1, green);
  110. cloudPlatform(278, -46, -56, 3, 20, 1, green);
  111. cloudPlatform(278, -46, -66, 3, 3, 1, green);
  112. cloudPlatform(278, -46, -76, 3, 3, 1, green);
  113. cloudPlatform(278, -46, -86, 60, 3, 1, green);
  114. cloudPlatform(350, -49, -85, 10, 10, 1, green);
  115. platform3D(350, -15, -80, 10, 30, 1, green);
  116. warpPlatform(350, 15, -80, 10, 10, 1, 0, 0, -1);
  117.  
  118. // water 1
  119. platform3D(-20, -100, 2, 40, 50, 10, blue, -20, -99.7, 2);
  120. platform3D(-20, -110, 2, 40, 10, 10, green);
  121. platform3D(-20, -210, 2, 40, 100, 10, blue, -20, -215, 2);
  122. platform3D(-6, -120, -6, 4, 4, 8, green);
  123. platform3D(13, -135, -8, 4, 4, 10, green);
  124. platform3D(5, -150, -12, 4, 4, 14, green);
  125. platform3D(-20, -150, -14, 4, 4, 16, green);
  126. platform3D(-18, -172, -10, 4, 4, 12, green);
  127. platform3D(3, -190, -10, 4, 4, 12, green);
  128. platform3D(-20, -220, -10, 40, 10, 12, green);
  129.  
  130. // water 2
  131. platform3D(-20, -370, 2, 40, 150, 10, blue, -18.5, -370, 2);
  132. platform3D(-20, -255, -6, 4, 4, 8, green);
  133. platform3D(-6, -270, -8, 4, 4, 10, green);
  134. platform3D(5, -280, -14, 4, 4, 16, green);
  135. platform3D(0, -290, -22, 4, 4, 24, green);
  136. platform3D(11, -321, -10, 4, 4, 12, green)
  137. platform3D(-6, -340, -14, 6, 6, 16, green);
  138. platform3D(11, -356, -19, 4, 4, 21, green);
  139. platform3D(-20, -380, -14, 40, 10, 16, green);
  140. platform3D(-6, -420, -14, 5, 40, 16, blue, -6, -422, -14);
  141. platform3D(-11, -450, -14, 5, 40, 16, blue, -11, -452, -14);
  142. platform3D(-6, -450, -14, 19, 5, 16, blue, -6, -452, -14);
  143. platform3D(13, -505, -14, 5, 60, 16, blue, 13, -507, -14);
  144. platform3D(-6, -505, -14, 19, 5, 16, blue, -6, -507, -14);
  145. platform3D(-11, -505, -14, 5, 20, 16, blue, -11, -507, -14);
  146. platform3D(-36, -490, -14, 25, 5, 16, blue, -36, -492, -14);
  147. platform3D(-46, -510, -14, 10, 40, 3, green);
  148. warpPlatform(-46, -525, -14, 10, 10, 3, 0, 0, -1);
  149.  
  150. // earth 1
  151.  
  152. platform3D(-200, -5, 0, 150, 10, 0, green);
  153. platform3D(-200, -155, 0, 10, 150, 0, green);
  154. platform3D(-218, -175, 0, 41, 20, 3, green);
  155. pushMover((x)=>(-60), (y)=>(-6+triangleX(y+15, 30, 20)), (z)=>(-12), 10, 10, 12, brown);
  156. pushMover((x)=>(-90), (y)=>(-6+triangleX(y, 30, 20)), (z)=>(-12), 10, 10, 12, brown);
  157. pushMover((x)=>(-100), (y)=>(-6+triangleX(y+30, 30, 20)), (z)=>(-12), 10, 10, 12, brown);
  158. pushMover((x)=>(-110), (y)=>(-6+triangleX(y, 30, 20)), (z)=>(-12), 10, 10, 12, brown);
  159. pushMover((x)=>(-120), (y)=>(-6+triangleX(y+30, 30, 20)), (z)=>(-12), 10, 10, 12, brown);
  160. pushMover((x)=>(-120), (y)=>(-6+triangleX(y+30, 30, 20)), (z)=>(-12), 10, 10, 12, brown);
  161. pushMover((x)=>(-165), (y)=>(-6+triangleX(y+30, 40, 10)), (z)=>(-12), 25, 10, 12, brown);
  162. platform3D(-190, -7, -30, 140, 2, 35, -190, -7, -31); // invisible
  163. platform3D(-200, 5, -30, 150, 2, 35, -200, 5, -31); // invisible
  164. pushMover((x)=>(-200), (y)=>(-25+triangleX(y, 30, 30)), (z)=>(-5), 10, 3, 5, brown);
  165. pushMover((x)=>(-200), (y)=>(-50), (z)=>(-35+triangleX(z, 30, 20)), 10, 10, 20, brown);
  166. pushMover((x)=>(-200), (y)=>(-65), (z)=>(-35+triangleX(z+15, 30, 20)), 10, 5, 20, brown);
  167. pushMover((x)=>(-200), (y)=>(-75), (z)=>(-35+triangleX(z+45, 30, 20)), 10, 5, 20, brown);
  168. pushMover((x)=>(-200), (y)=>(-85), (z)=>(-35+triangleX(z+30, 30, 20)), 10, 5, 20, brown);
  169. pushMover((x)=>(-200), (y)=>(-105), (z)=>(-35+triangleX(z+50, 25, 20)), 10, 5, 20, brown);
  170. pushMover((x)=>(-200), (y)=>(-110), (z)=>(-35+triangleX(z+44, 25, 20)), 10, 5, 20, brown);
  171. pushMover((x)=>(-200), (y)=>(-115), (z)=>(-35+triangleX(z+38, 25, 20)), 10, 5, 20, brown);
  172. pushMover((x)=>(-200), (y)=>(-120), (z)=>(-35+triangleX(z+32, 25, 20)), 10, 5, 20, brown);
  173. pushMover((x)=>(-200), (y)=>(-125), (z)=>(-35+triangleX(z+26, 25, 20)), 10, 5, 20, brown);
  174. pushMover((x)=>(-200), (y)=>(-130), (z)=>(-35+triangleX(z+20, 25, 20)), 10, 5, 20, brown);
  175. pushMover((x)=>(-200), (y)=>(-135), (z)=>(-35+triangleX(z+12, 25, 20)), 10, 5, 20, brown);
  176. pushMover((x)=>(-200), (y)=>(-140), (z)=>(-35+triangleX(z+6, 25, 20)), 10, 5, 20, brown);
  177. pushMover((x)=>(-200), (y)=>(-155), (z)=>(-35+triangleX(z+45, 25, 20)), 10, 10, 20, brown);
  178.  
  179. // earth 2
  180. pushMover((x)=>(-230), (y)=>(-180+triangleX(y,30,20)), (z)=>(-6), 5, 10, 10, brown);
  181. pushMover((x)=>(-240), (y)=>(-180+triangleX(y+11,40,20)), (z)=>(-12), 5, 10, 10, brown);
  182. pushMover((x)=>(-250), (y)=>(-180+triangleX(y+26,50,20)), (z)=>(-18), 5, 10, 10, brown);
  183. pushMover((x)=>(-260), (y)=>(-185+triangleX(y+15,20,20)), (z)=>(-40), 5, 20, 25, brown);
  184. pushMover((x)=>(-280), (y)=>(-170), (z)=>(-60+triangleX(z, 40, 20)), 10, 10, 10, brown);
  185. pushMover((x)=>(-300), (y)=>(-170), (z)=>(-78+triangleX(z, 40, 20)), 10, 10, 28, brown);
  186. platform3D(-360, -180, -50, 50, 30, 3, green);
  187. platform3D(-359, -170, -40, 20, 10, 3, green);
  188. warpPlatform(-339, -170, -40, 10, 10, 1, 0, 0, -1);
  189.  
  190. // fire part 1
  191. platform3D(-10, 60, -3, 6, 6, 1, red);
  192. platform3D(-10, 80, -3, 6, 6, 1, red);
  193. platform3D(0, 90, -5, 6, 6, 1, red);
  194. platform3D(10, 100, -7, 6, 6, 1, red);
  195. platform3D(0, 120, 0, 8, 8, 1, red);
  196. platform3D(-18, 136, -2, 6, 6, 1, red);
  197. platform3D(3, 152, -7, 6, 6, 1, red);
  198. platform3D(3, 172, -10, 6, 6, 1, red);
  199. platform3D(-11, 183, -15, 6, 6, 1, red);
  200. platform3D(5, 195, -20, 6, 6, 1, red);
  201. platform3D(5, 220, -10, 8, 8, 1, red);
  202. platform3D(15, 250, -10, 8, 8, 1, red);
  203. platform3D(0, 280, 0, 8, 8, 1, red);
  204. platform3D(-15, 300, 0, 40, 10, 3, green);
  205. fireWall(-30, 50, -40, 60, 250, 50, color(255, 128, 0, 0.1), 80, 0.2);
  206.  
  207. // fire part 2
  208. platform3D(4, 320, -5, 2, 50, 1, red);
  209. platform3D(2, 395, 0, 6, 6, 1, red);
  210. bobbingPlatform3D(8, 420, -5, 10, 10, 1, red, 4, 0, 10, 2);
  211. bobbingPlatform3D(-8, 440, -5, 10, 10, 1, red, 6, 0, 10, 2);
  212. bobbingPlatform3D(0, 460, -5, 10, 10, 1, red, 6, 0, 10, 0);
  213. bobbingPlatform3D(5, 480, -5, 10, 10, 1, red, 6, 1.5, 10, 2);
  214. bobbingPlatform3D(5, 500, -15, 12, 6, 1, red, 6, 1.5, 10, 0);
  215. bobbingPlatform3D(5, 520, -15, 12, 6, 1, red, 8, 0, 10, 0);
  216. bobbingPlatform3D(5, 540, -15, 12, 6, 1, red, 10, 1.5, 10, 0);
  217. bobbingPlatform3D(5, 560, -15, 12, 6, 1, red, 4, 1.5, 10, 0);
  218. platform3D(0, 580, 0, 6, 6, 1, red);
  219. platform3D(-15, 600, 0, 40, 10, 3, green);
  220. fireWall(-30, 300, -40, 60, 300, 50, color(255, 128, 0, 0.1), 390, 0.45);
  221. warpPlatform(0, 615, 0, 10, 10, 1, 0, 0, -1);
  222.  
  223. // light
  224. if (player.checkpoints >= 9) {
  225. springPlatform(10, 10, -5, 10, 10, 3, 2);
  226. springPlatform(-20, -20, -25, 10, 10, 3, 2);
  227. springPlatform(-30, -20, -60, 10, 10, 3, 2.5);
  228. springPlatform(-30, 20, -110, 10, 10, 3, 2);
  229. springPlatform(0, 0, -140, 10, 10, 3, 5);
  230. springPlatform(-10, -10, -380, 10, 30, 3, 2);
  231. springPlatform(-10, 10, -380, 10, 30, 3, 2);
  232. springPlatform(-10, 0, -380, 10, 10, 3, 2);
  233. springPlatform(10, 0, -380, 10, 10, 3, 2);
  234. platform3D(0, 0, -400, 10, 10, 3, green);
  235. }
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243. addCheckpoint(0, 0, 0);
  244. addCheckpoint(5, 305, 0); // fire 1
  245. addCheckpoint(5, 605, 0); // fire 2
  246. addCheckpoint(188, -35, -80); // air 1
  247. addCheckpoint(355, 0, -80); // air 2
  248. addCheckpoint(0, -215, -10); // water 1
  249. addCheckpoint(-41, -490, -14); // water 2
  250. addCheckpoint(-198, -165, 0); // earth 1
  251. addCheckpoint(-349, -165, -40); // earth 2
  252. addCheckpoint(5, 5, -400); // ending
Advertisement
Add Comment
Please, Sign In to add comment