Advertisement
Elnidas

Untitled

Dec 6th, 2020
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 83.38 KB | None | 0 0
  1. import Escenario from '../gameObjects/Escenario.js';
  2. class Scene_play extends Phaser.Scene {
  3. constructor() {
  4. super({ key: "Scene_play" });
  5. this.escenasActivas = [false, false];
  6.  
  7. this.escenarios = [];
  8. }
  9. init(data) {
  10. this.soundManager = data.soundManager;
  11. this.data=data;
  12.  
  13.  
  14. }
  15. preload() {
  16. // let aux = [0, 1];
  17. // let tamanio = 3;
  18. // let posiciones = [];
  19. // for (let i = 0; i < tamanio; i++) {
  20. // let numero = Math.round(Math.random() * (tamanio - 1));
  21. // posiciones[i] = aux[numero];
  22. // aux.splice(numero, 1);
  23. // }
  24.  
  25. }
  26. create() {
  27.  
  28.  
  29. /*
  30. let tamanio=escenas.length;
  31. let i=0;
  32. for(tamanio;tamanio>0;tamanio--){
  33. if(tamanio==1){
  34. escenasP1[i]=escenas[0];
  35. escenasP2[i]=escenas[0];
  36.  
  37. }else{
  38. let numero=Math.round(Math.random()*(tamanio-1));
  39. console.log("El numerito : "+numero);
  40. escenasP1[i]=escenas[numero];
  41. escenasP2[i]=escenas[numero];
  42. escenas.splice(numero,1);
  43. i++;
  44. }
  45. console.log("Iterando y tal")
  46.  
  47. }
  48. console.log(escenasP1,escenasP2);
  49. //*/
  50.  
  51.  
  52.  
  53.  
  54.  
  55. //Pensar esto un pcoo mejor
  56. this.escenarios[0] = new Escenario("Cinta", 0, true);
  57. this.escenarios[1] = new Escenario("Contador", 1, false);
  58. this.escenarios[2] = new Escenario("Nieve", 4, false);
  59. this.escenarios[3] = new Escenario("Electricidad", 2, true);
  60. this.escenarios[4] = new Escenario("Laboratorio", 3, false);
  61.  
  62. this.physics.world.setBounds(0, 0, 5800, this.game.canvas.height);
  63. var that = this;
  64.  
  65. this.end = { player1: false, player2: false };
  66.  
  67.  
  68. //Factor de suma 1180 * this.escenarios[i].pos
  69.  
  70. //Esquema : this.add.image( PosicionX + Factor de suma, PosicionX, "Nombre")
  71.  
  72. //Player 1//
  73.  
  74.  
  75.  
  76. this.playerU = this.physics.add.sprite(0, this.game.canvas.height / 2 - 50, 'P1');
  77. this.playerU.play('IdleDerechaP1');
  78. this.playerU.setScale(0.15).refreshBody();
  79. this.playerU.body.collideWorldBounds = true;
  80. this.playerU.id = 0;
  81. this.playerU.velocidad = 300;
  82. this.playerU.time = 0;
  83. this.playerU.setDepth(1000);
  84. this.playerU.name=this.data.names.p1;
  85.  
  86. //Player 2//
  87.  
  88. this.playerD = this.physics.add.sprite(0, this.game.canvas.height - 50, 'P2');
  89. this.playerD.play('IdleDerechaP2');
  90. this.playerD.setScale(0.15).refreshBody();
  91. this.playerD.body.collideWorldBounds = true;
  92. this.playerD.id = 1;
  93. this.playerD.time = 0;
  94. this.playerD.velocidad = 300;
  95. this.playerD.setDepth(1000);
  96. this.playerD.name=this.data.names.p2;
  97.  
  98. //Cargar sonido
  99.  
  100.  
  101. this.soundManager.play('Musica_fondo',{loop:true})
  102.  
  103. // this.soundManager.once('looped',()=>{
  104. // this.soundManager.play('Musica_fondo')
  105. // })
  106.  
  107. //Escenario 1 Gimnasio
  108.  
  109.  
  110. //Parte jugador 1
  111.  
  112. let gimU = this.add.image(0 + 1180 * this.escenarios[0].pos, 0, "Gimnasio").setOrigin(0, 0);
  113.  
  114. gimU.displayHeight = this.game.canvas.height / 2;
  115. gimU.displayWidth = this.game.canvas.width;
  116. gimU.setDepth(-9999)
  117.  
  118. this.blurGU = this.add.image(0 + 1180 * this.escenarios[0].pos, 0, "GimnasioBlur").setOrigin(0, 0);
  119. this.blurGU.displayHeight = this.game.canvas.height / 2 - 10;
  120. this.blurGU.displayWidth = this.game.canvas.width;
  121. this.blurGU.alpha = 0;
  122.  
  123. let cinU = this.add.image(1030 + 1180 * this.escenarios[0].pos, 89, "cintaSprite")
  124.  
  125. let cintaU = this.physics.add.image(1024 + 1180 * this.escenarios[0].pos, 121, "muro")
  126. cintaU.displayHeight = 5;
  127. cintaU.displayWidth = 78
  128.  
  129.  
  130. cinU.setScale(0.30);
  131.  
  132.  
  133.  
  134. let groupCintaU = this.add.group()
  135. groupCintaU.add(cintaU);
  136.  
  137.  
  138.  
  139. this.particlesCPU = this.add.particles('flares')
  140. this.particlesCPU.depth = -10
  141.  
  142. this.PCU = this.particlesCPU.createEmitter({
  143. x: { min: cinU.x - 50, max: cinU.x + 50 },
  144. y: cintaU.y + 50,
  145. lifespan: 3000,
  146. speedY: { min: -60, max: -100 },
  147. scale: { start: 0.3, end: 0 },
  148. quantity: 1,
  149. frame: 'white',
  150. frequency: 300,
  151. tint: 0x2ECC71,
  152. blendMode: 'ADD',
  153.  
  154. });
  155.  
  156.  
  157. //Parte jugador 2
  158.  
  159. let gimD = this.add.image(0 + 1180 * this.escenarios[0].pos, this.game.canvas.height / 2, "Gimnasio").setOrigin(0, 0);
  160.  
  161. gimD.displayHeight = this.game.canvas.height / 2;
  162. gimD.displayWidth = this.game.canvas.width;
  163. gimD.setDepth(-9999)
  164.  
  165. this.blurGD = this.add.image(0 + 1180 * this.escenarios[0].pos, this.game.canvas.height / 2, "GimnasioBlur").setOrigin(0, 0);
  166. this.blurGD.displayHeight = this.game.canvas.height / 2;
  167. this.blurGD.displayWidth = this.game.canvas.width;
  168. this.blurGD.alpha = 0;
  169.  
  170. //se ha modificado la posición de la colisión de la cinta para junto a un sprite
  171. let cintaD = this.physics.add.image(1024 + 1180 * this.escenarios[0].pos, 483, "muro")
  172.  
  173. cintaD.displayHeight = 5;
  174. cintaD.displayWidth = 78
  175.  
  176. let cinD = this.add.image(1030 + 1180 * this.escenarios[0].pos, 449, "cintaSprite") //no oficial
  177.  
  178. cinD.setScale(0.30);
  179.  
  180. //Plataformas jugador 1
  181. this.crearPlataformasGimnasioP1();
  182.  
  183. //Plataformas jugador 2
  184. this.crearPlataformasGimnasioP2();
  185.  
  186. //Power Up jugador 1
  187. this.crearSpeedUpP1(825, 300, this.escenarios[0].pos);
  188.  
  189. this.crearMenosTP1(60, 85, this.escenarios[0].pos);
  190.  
  191. //Power Up jugador 2
  192. this.crearSpeedUpP2(825, 300, this.escenarios[0].pos);
  193.  
  194. this.crearMenosTP2(60, 85, this.escenarios[0].pos);
  195.  
  196.  
  197.  
  198.  
  199. // let pCintaD= particles.createEmitter({
  200. // x: { min: cintaD.x-50, max: cintaD.x+50 },
  201. // y: cintaD.y+100,
  202. // lifespan: 3000,
  203. // speedY: { min: -60, max: -100 },
  204. // scale: { start: 0.3, end: 0 },
  205. // quantity: 1,
  206. // frame:'white',
  207. // frequency: 300,
  208. // blendMode: 'ADD'
  209. // });
  210.  
  211.  
  212. //Power Up jugador 2
  213. this.crearSpeedUpP2();
  214.  
  215. this.particlesCPD = this.add.particles('flares')
  216. this.particlesCPD.depth = -10
  217.  
  218. this.PCD = this.particlesCPD.createEmitter({
  219. x: { min: cinD.x - 50, max: cinD.x + 50 },
  220. y: cintaD.y + 50,
  221. lifespan: 3000,
  222. speedY: { min: -60, max: -100 },
  223. scale: { start: 0.3, end: 0 },
  224. quantity: 1,
  225. frame: 'white',
  226. frequency: 300,
  227. tint: 0x2ECC71,
  228. blendMode: 'ADD',
  229.  
  230. });
  231.  
  232. // let pCintaD= particles.createEmitter({
  233. // x: { min: cintaD.x-50, max: cintaD.x+50 },
  234. // y: cintaD.y+100,
  235. // lifespan: 3000,
  236. // speedY: { min: -60, max: -100 },
  237. // scale: { start: 0.3, end: 0 },
  238. // quantity: 1,
  239. // frame:'white',
  240. // frequency: 300,
  241. // blendMode: 'ADD'
  242. // });
  243.  
  244.  
  245.  
  246. //Escenario 2 Contador
  247.  
  248. //Parte jugador 1
  249.  
  250. let escU2 = this.add.image(0 + 1180 * this.escenarios[1].pos, 0, "Contador").setOrigin(0, 0);
  251.  
  252. escU2.displayHeight = this.game.canvas.height / 2;
  253. escU2.displayWidth = this.game.canvas.width;
  254.  
  255.  
  256. let pContU = this.add.image(830 + 1180 * this.escenarios[1].pos, 242, "spriteCont").setOrigin(0, 0);
  257. pContU.displayHeight = this.game.canvas.height * 0.1;
  258. pContU.displayWidth = this.game.canvas.width * 0.08;
  259.  
  260. let pruebaContador = this.physics.add.image(830 + 1180 * this.escenarios[1].pos, 309, "muro").setOrigin(0, 0);
  261. pruebaContador.setImmovable(true)
  262. pruebaContador.displayWidth = 95;
  263. pruebaContador.displayHeight = 5;
  264. pruebaContador.alpha = 0;
  265.  
  266.  
  267. this.particlesContPU = this.add.particles('flares')
  268. this.particlesContPU.depth = 10
  269.  
  270. this.PCuP = this.particlesContPU.createEmitter({
  271. x: { min: pContU.x + 35 - 50, max: pContU.x + 35 + 50 },
  272. y: pContU.y + 50,
  273. lifespan: 3000,
  274. speedY: { min: -60, max: -100 },
  275. scale: { start: 0.3, end: 0 },
  276. quantity: 1,
  277. frame: 'white',
  278. frequency: 300,
  279. tint: 0x2ECC71,
  280. blendMode: 'ADD',
  281.  
  282. });
  283.  
  284.  
  285.  
  286.  
  287.  
  288. this.escBU2 = this.add.image(0 + 1180 * this.escenarios[1].pos, 0, "ContadorBlur").setOrigin(0, 0)
  289. this.escBU2.displayHeight = this.game.canvas.height / 2;
  290. this.escBU2.displayWidth = this.game.canvas.width;
  291. this.escBU2.alpha = 0;
  292. this.escBU2.setDepth(11);
  293.  
  294.  
  295. //Parte jugador 2
  296.  
  297. let escD2 = this.add.image(0 + 1180 * this.escenarios[1].pos, this.game.canvas.height / 2, "Contador").setOrigin(0, 0);
  298.  
  299. escD2.displayHeight = this.game.canvas.height / 2;
  300. escD2.displayWidth = this.game.canvas.width;
  301.  
  302.  
  303.  
  304. let pContD = this.add.image(830 + 1180 * this.escenarios[1].pos, 602, "spriteCont").setOrigin(0, 0);
  305. pContD.displayHeight = this.game.canvas.height * 0.1;
  306. pContD.displayWidth = this.game.canvas.width * 0.08;
  307.  
  308. let pruebaContador2 = this.physics.add.image(830 + 1180 * this.escenarios[1].pos, 309 + this.game.canvas.height / 2, "muro").setOrigin(0, 0);
  309. pruebaContador2.setImmovable(true)
  310. pruebaContador2.displayWidth = 95;
  311. pruebaContador2.displayHeight = 5;
  312. pruebaContador2.alpha = 0;
  313.  
  314. this.particlesContPD = this.add.particles('flares')
  315. this.particlesContPD.depth = 10
  316.  
  317. this.PCuP = this.particlesContPD.createEmitter({
  318. x: { min: pContD.x + 35 - 50, max: pContD.x + 35 + 50 },
  319. y: pContD.y + 50,
  320. lifespan: 3000,
  321. speedY: { min: -60, max: -100 },
  322. scale: { start: 0.3, end: 0 },
  323. quantity: 1,
  324. frame: 'white',
  325. frequency: 300,
  326. tint: 0x2ECC71,
  327. blendMode: 'ADD',
  328.  
  329. });
  330.  
  331.  
  332.  
  333.  
  334. this.escBU22 = this.add.image(0 + 1180 * this.escenarios[1].pos, this.game.canvas.height / 2, "ContadorBlur").setOrigin(0, 0)
  335.  
  336. this.escBU22.displayHeight = this.game.canvas.height / 2;
  337. this.escBU22.displayWidth = this.game.canvas.width;
  338. this.escBU22.alpha = 0;
  339. this.escBU22.setDepth(11)
  340.  
  341.  
  342. //Plataformas jugador 1
  343. this.crearPlataformasContador1();
  344.  
  345. //Plataformas jugador 2
  346. this.crearPlataformasContador2();
  347.  
  348. //Power Up jugador 1
  349. this.crearMenosTP1(720, 300, this.escenarios[1].pos);
  350.  
  351. //Power Up jugador 2
  352. this.crearMenosTP2(720, 300, this.escenarios[1].pos);
  353.  
  354. //Escenario 3 Nieve
  355.  
  356. //Parte jugador 1
  357.  
  358. let escU3 = this.add.image(0 + 1180 * this.escenarios[2].pos, 0, "Nieve").setOrigin(0, 0);
  359.  
  360. escU3.displayHeight = this.game.canvas.height / 2;
  361. escU3.displayWidth = this.game.canvas.width;
  362.  
  363. let banderaU = this.physics.add.image(925 + 1180 * this.escenarios[2].pos, 115, "flag").setOrigin(0, 0);
  364. banderaU.displayHeight = this.game.canvas.height * 0.1;
  365. banderaU.displayWidth = this.game.canvas.width * 0.08;
  366. banderaU.setImmovable(true)
  367. banderaU.alpha = 1;
  368. this.crearPlataformasNieve1();
  369.  
  370. //Parte jugador 2
  371.  
  372. let escD3 = this.add.image(0 + 1180 * this.escenarios[2].pos, this.game.canvas.height / 2, "Nieve").setOrigin(0, 0);
  373.  
  374. escD3.displayHeight = this.game.canvas.height / 2;
  375. escD3.displayWidth = this.game.canvas.width;
  376.  
  377. let banderaD = this.physics.add.image(925 + 1180 * this.escenarios[2].pos, 115 + this.game.canvas.height / 2, "flag").setOrigin(0, 0);
  378. banderaD.displayHeight = this.game.canvas.height * 0.1;
  379. banderaD.displayWidth = this.game.canvas.width * 0.08;
  380. banderaD.setImmovable(true)
  381. this.crearPlataformasNieve2();
  382.  
  383.  
  384.  
  385.  
  386.  
  387. //Escenario 4 Electricidad
  388.  
  389. //Parte jugador 1
  390.  
  391. let escU4 = this.add.image(0 + 1180 * this.escenarios[3].pos, 0, "Electricidad").setOrigin(0, 0);
  392.  
  393. escU4.displayHeight = this.game.canvas.height / 2;
  394. escU4.displayWidth = this.game.canvas.width;
  395.  
  396.  
  397. let pruebaElectricidadU = this.physics.add.image(770 + 1180 * this.escenarios[3].pos, 90, "logo").setOrigin(0, 0);
  398. pruebaElectricidadU.displayHeight = 140;
  399. pruebaElectricidadU.displayWidth = 140;
  400. pruebaElectricidadU.setImmovable(true)
  401. pruebaElectricidadU.alpha = 0;
  402.  
  403. //AÑADIR LAS PARTÍCULAS A LA PRUEBA DE ELECTRICIDAD
  404.  
  405. this.blurElectricidadU = this.add.image(0 + 1180 * this.escenarios[3].pos, 0, "ElectricidadBlur").setOrigin(0, 0);
  406. this.blurElectricidadU.displayHeight = this.game.canvas.height / 2 - 10;
  407. this.blurElectricidadU.displayWidth = this.game.canvas.width;
  408. this.blurElectricidadU.alpha = 0;
  409.  
  410. //Plataformas jugador 1
  411. this.crearPlataformasElectricidad1(that);
  412.  
  413. //Plataformas jugador 2
  414. this.crearPlataformasElectricidad2(that);
  415.  
  416. //Power Up jugador 1
  417. this.crearMenosTP1(15, 50, this.escenarios[3].pos);
  418.  
  419. //Power Up jugador 2
  420. this.crearMenosTP2(15, 50, this.escenarios[3].pos);
  421.  
  422.  
  423. //Parte jugador 2
  424.  
  425. let escD4 = this.add.image(0 + 1180 * this.escenarios[3].pos, this.game.canvas.height / 2, "Electricidad").setOrigin(0, 0);
  426.  
  427. escD4.displayHeight = this.game.canvas.height / 2;
  428. escD4.displayWidth = this.game.canvas.width;
  429. escD4.setDepth(-2000);
  430.  
  431. let pruebaElectricidadD = this.physics.add.image(770 + 1180 * this.escenarios[3].pos, 450, "logo").setOrigin(0, 0);
  432. pruebaElectricidadD.displayHeight = 140;
  433. pruebaElectricidadD.displayWidth = 140;
  434. pruebaElectricidadD.setImmovable(true)
  435. pruebaElectricidadD.alpha = 0;
  436.  
  437. this.blurElectricidadD = this.add.image(0 + 1180 * this.escenarios[3].pos, this.game.canvas.height / 2 + 10, "ElectricidadBlur").setOrigin(0, 0);
  438. this.blurElectricidadD.displayHeight = this.game.canvas.height / 2;
  439. this.blurElectricidadD.displayWidth = this.game.canvas.width;
  440. this.blurElectricidadD.alpha = 0;
  441.  
  442.  
  443.  
  444. //Escenario yiieePUm Laboratorio
  445.  
  446. //Jugador 1
  447.  
  448. let escU5 = this.add.image(0 + 1180 * this.escenarios[4].pos, 0, "Laboratorio").setOrigin(0, 0);
  449.  
  450. escU5.displayHeight = this.game.canvas.height / 2;
  451. escU5.displayWidth = this.game.canvas.width;
  452.  
  453.  
  454. let pruebaLaboratorioU = this.physics.add.image(800 + 1180 * this.escenarios[4].pos, 185, "Ordenador").setOrigin(0, 0);
  455. pruebaLaboratorioU.displayHeight = this.game.canvas.height * 0.1;
  456. pruebaLaboratorioU.displayWidth = this.game.canvas.width * 0.08;
  457. pruebaLaboratorioU.setImmovable(true)
  458.  
  459.  
  460. this.blurLaboratorioU = this.add.image(0 + 1180 * this.escenarios[4].pos, 0, "LaboratorioBlur").setOrigin(0, 0);
  461. this.blurLaboratorioU.displayHeight = this.game.canvas.height / 2 - 10;
  462. this.blurLaboratorioU.displayWidth = this.game.canvas.width;
  463. this.blurLaboratorioU.alpha = 0;
  464.  
  465. this.crearPlataformasLaboratorio1();
  466.  
  467. //POWER UPS JUGADOR 1
  468. this.crearSpeedUpP1(825, 300, this.escenarios[4].pos);
  469.  
  470.  
  471. //Jugador 2
  472.  
  473. let escD5 = this.add.image(0 + 1180 * this.escenarios[4].pos, this.game.canvas.height / 2, "Laboratorio").setOrigin(0, 0);
  474.  
  475. escD5.displayHeight = this.game.canvas.height / 2;
  476. escD5.displayWidth = this.game.canvas.width;
  477.  
  478. let pruebaLaboratorioD = this.physics.add.image(800 + 1180 * this.escenarios[4].pos, 545, "Ordenador").setOrigin(0, 0);
  479. pruebaLaboratorioD.displayHeight = this.game.canvas.height * 0.1;
  480. pruebaLaboratorioD.displayWidth = this.game.canvas.width * 0.08;
  481. pruebaLaboratorioD.setImmovable(true)
  482. //pruebaElectricidadD.alpha = 0;
  483.  
  484. this.blurLaboratorioD = this.add.image(0 + 1180 * this.escenarios[4].pos, this.game.canvas.height / 2 + 10, "LaboratorioBlur").setOrigin(0, 0);
  485. this.blurLaboratorioD.displayHeight = this.game.canvas.height / 2;
  486. this.blurLaboratorioD.displayWidth = this.game.canvas.width;
  487. this.blurLaboratorioD.alpha = 0;
  488.  
  489. this.crearPlataformasLaboratorio2();
  490.  
  491. //POWER UPS JUGADOR 2
  492. this.crearSpeedUpP2(825, 300, this.escenarios[4].pos);
  493.  
  494.  
  495.  
  496. //Limites//
  497.  
  498.  
  499. //Suelo jugador 1
  500.  
  501. let muro = this.add.image(0, this.game.canvas.height / 2, "muro").setOrigin(0, 0);
  502. muro.displayHeight = 1;
  503. muro.displayWidth = 5800;
  504. muro.alpha = 0;
  505.  
  506. //Suelo jugador 2
  507.  
  508. let muro2 = this.add.image(0, this.game.canvas.height - 1, "muro").setOrigin(0, 0);
  509. muro2.displayHeight = 1;
  510. muro2.displayWidth = 5800;
  511. muro2.alpha = 0;
  512.  
  513. //Paredes
  514.  
  515. let pared1 = this.add.image(1080, 0, "muro").setOrigin(0, 0);
  516. pared1.displayHeight = this.game.canvas.height;
  517. pared1.displayWidth = 100;
  518. pared1.alpha = 0;
  519. let pared2 = this.add.image(2260, 0, "muro").setOrigin(0, 0);
  520. pared2.displayHeight = this.game.canvas.height;
  521. pared2.displayWidth = 100;
  522. pared2.alpha = 0;
  523. let pared3 = this.add.image(3440, 0, "muro").setOrigin(0, 0);
  524. pared3.displayHeight = this.game.canvas.height;
  525. pared3.displayWidth = 100;
  526. pared3.alpha = 0;
  527. let pared4 = this.add.image(4620, 0, "muro").setOrigin(0, 0);
  528. pared4.displayHeight = this.game.canvas.height;
  529. pared4.displayWidth = 100;
  530. pared4.alpha = 0;
  531.  
  532. this.plataformas = this.physics.add.staticGroup();
  533. this.plataformas.add(muro);
  534. this.plataformas.add(muro2);
  535.  
  536. this.paredes = this.physics.add.staticGroup();
  537. this.paredes.add(pared1)
  538. this.paredes.add(pared2)
  539. this.paredes.add(pared3)
  540. this.paredes.add(pared4)
  541.  
  542.  
  543.  
  544.  
  545. //controles//
  546.  
  547. //Player 2
  548.  
  549.  
  550.  
  551. this.keyboardP2 = this.input.stopPropagation().keyboard.addKeys('LEFT,RIGHT,UP,DOWN,SPACE,ESC');
  552.  
  553. this.input.keyboard.on('keyup-' + 'LEFT', this.unlockP2.bind(this));
  554. this.input.keyboard.on('keyup-' + 'RIGHT', this.unlockP2.bind(this));
  555. this.input.keyboard.on('keyup-' + 'UP', this.unlockP2.bind(this));
  556. this.input.keyboard.on('keyup-' + 'DOWN', this.unlockP2.bind(this));
  557. this.input.keyboard.on('keyup-' + 'SPACE', this.unlockP2.bind(this));
  558.  
  559. this.input.keyboard.on('keyup-' + 'ESC', this.unlockP2.bind(this));
  560.  
  561. this.keyLockP2 = false;
  562.  
  563. //Player 1
  564.  
  565. this.keyboardP1 = this.input.stopPropagation().keyboard.addKeys('D,A,W,S,E');
  566.  
  567. this.input.keyboard.on('keyup-' + 'D', this.unlockP1.bind(this));
  568. this.input.keyboard.on('keyup-' + 'A', this.unlockP1.bind(this));
  569. this.input.keyboard.on('keyup-' + 'W', this.unlockP1.bind(this));
  570. this.input.keyboard.on('keyup-' + 'S', this.unlockP1.bind(this));
  571. this.input.keyboard.on('keyup-' + 'E', this.unlockP1.bind(this));
  572.  
  573.  
  574. //Camaras
  575.  
  576. //Tamanio camara
  577. this.cam1 = this.cameras.main.setSize(this.game.canvas.width, this.game.canvas.height / 2).setName('Camara 1');
  578.  
  579. //Bordes camara para que no muestre la parte exterior del mapa
  580. //Lo que quieres que se muestre basicamente
  581. this.cam1.setBounds(0, 0, this.game.canvas.width, this.game.canvas.height / 2)
  582. //Para que persiga al pj
  583. this.cam1.startFollow(this.playerU, true);
  584. this.cam1.setZoom(1.8)
  585.  
  586.  
  587. this.cam2 = this.cameras.add(0, this.game.canvas.height / 2, this.game.canvas.width, this.game.canvas.height / 2).setName('Camara 2');
  588.  
  589.  
  590. this.cam2.setBounds(0, this.game.canvas.height / 2, this.game.canvas.width, this.game.canvas.height / 2)
  591.  
  592. this.cam2.startFollow(this.playerD, true);
  593.  
  594. this.cam2.setZoom(1.8)
  595.  
  596.  
  597.  
  598.  
  599. //Fisicas
  600.  
  601.  
  602. this.physics.add.collider(this.playerU, this.plataformas);
  603. this.physics.add.collider(this.playerD, this.plataformas);
  604. this.physics.add.collider(this.playerU, this.paredes);
  605. this.physics.add.collider(this.playerD, this.paredes);
  606.  
  607.  
  608.  
  609.  
  610. this.CP1 = this.physics.add.overlap(this.playerU, groupCintaU, () => { this.Prueba(this.playerU) }, null, this);
  611. this.CP2 = this.physics.add.overlap(this.playerD, cintaD, () => { this.Prueba(this.playerD) }, null, this);
  612. this.CoP1 = this.physics.add.overlap(this.playerU, pruebaContador, () => { this.Prueba(this.playerU) }, null, this);
  613. this.CoP2 = this.physics.add.overlap(this.playerD, pruebaContador2, () => { this.Prueba(this.playerD) }, null, this);
  614. this.EP1 = this.physics.add.overlap(this.playerU, pruebaElectricidadU, () => { this.Prueba(this.playerU) }, null, this);
  615. this.EP2 = this.physics.add.overlap(this.playerD, pruebaElectricidadD, () => { this.Prueba(this.playerD) }, null, this);
  616. this.LP1 = this.physics.add.overlap(this.playerU, pruebaLaboratorioU, () => { this.Prueba(this.playerU) }, null, this);
  617. this.LP2 = this.physics.add.overlap(this.playerD, pruebaLaboratorioD, () => { this.Prueba(this.playerD) }, null, this);
  618. this.BP1 = this.physics.add.overlap(this.playerU, banderaU, () => { this.endP1(banderaU) }, null, this);
  619. this.BP2 = this.physics.add.overlap(this.playerD, banderaD, () => { this.endP2(banderaD) }, null, this);
  620.  
  621.  
  622. //Cronometro
  623.  
  624. this.playP1 = false;
  625. this.playP2 = false;
  626. this.croP1 = 0;
  627. this.croP2 = 0;
  628.  
  629. this.TiempoP1 = this.add.bitmapText(750, 90, 'Digitalism', "00 : 00 : 00", 22)
  630. this.TiempoP1.setScrollFactor(0, 0)
  631.  
  632. this.TiempoP2 = this.add.bitmapText(750, 90, 'Digitalism', "00 : 00 : 00", 22)
  633. this.TiempoP2.setScrollFactor(0, 0)
  634.  
  635. //Ignorasiones
  636.  
  637. this.cam1.ignore(this.TiempoP2);
  638. this.cam1.ignore(this.particlesCPD);
  639. this.cam2.ignore(this.TiempoP1);
  640.  
  641.  
  642.  
  643. //Ajustes
  644.  
  645. this.time.addEvent({
  646. delay: 100,
  647. callback: this.delayDone,
  648. callbackScope: this,
  649. loop: false
  650. });
  651.  
  652.  
  653.  
  654. }
  655. update() {
  656. //console.log("Camara: "+this.cam2.midPoint.x)
  657.  
  658. // Control personaje 2
  659.  
  660. if (!this.escenasActivas[1]) {
  661.  
  662. if (this.keyboardP2.LEFT.isDown === true) {
  663. this.playerD.body.setVelocityX(-this.playerD.velocidad);
  664. if (this.playerD.body.touching.down) {
  665. this.playerD.anims.play("CorrerIzquierdaP2", true);
  666. } else {
  667. this.playerD.anims.play("SaltoIzquierdaP2", true);
  668. }
  669.  
  670. }
  671. if (this.keyboardP2.RIGHT.isDown === true) {
  672. console.log("Derechaa")
  673. this.playerD.body.setVelocityX(this.playerD.velocidad);
  674. if (this.playerD.body.touching.down) {
  675. this.playerD.anims.play("CorrerDerechaP2", true);
  676. } else {
  677. this.playerD.anims.play("SaltoDerechaP2", true);
  678. }
  679. }
  680. if (this.keyboardP2.UP.isDown === true && this.playerD.body.touching.down) {
  681. this.playerD.setVelocityY(-750);
  682. }
  683.  
  684.  
  685. if (this.keyboardP2.LEFT.isDown === false && this.keyboardP2.RIGHT.isDown === false && this.keyboardP2.UP.isDown === false) {
  686. if (this.playerD.body.velocity.x > 0) {
  687. this.playerD.anims.stop();
  688. this.playerD.anims.play("IdleDerechaP2", true);
  689. }
  690. if (this.playerD.body.velocity.x < 0) {
  691. this.playerD.anims.stop();
  692. this.playerD.anims.play("IdleIzquierdaP2", true);
  693. }
  694.  
  695.  
  696. this.playerD.body.setVelocityX(0);
  697.  
  698.  
  699. }
  700.  
  701.  
  702. }
  703. // Personaje 1
  704. if (!this.escenasActivas[0]) {
  705.  
  706. if (this.keyboardP1.W.isDown === true && this.playerU.body.touching.down) {
  707. this.playerU.setVelocityY(-750); //cambiar para que salte menos y poder bajar plataformas
  708.  
  709. }
  710.  
  711. if (this.keyboardP1.A.isDown === true) {
  712. this.playerU.body.setVelocityX(-this.playerU.velocidad);
  713. if (this.playerU.body.touching.down) {
  714. this.playerU.anims.play("CorrerIzquierdaP1", true);
  715. } else {
  716. this.playerU.anims.play("SaltoIzquierdaP1", true);
  717. }
  718.  
  719. }
  720. if (this.keyboardP1.D.isDown === true) {
  721. this.playerU.body.setVelocityX(this.playerU.velocidad);
  722. if (this.playerU.body.touching.down) {
  723. this.playerU.anims.play("CorrerDerechaP1", true);
  724. } else {
  725. this.playerU.anims.play("SaltoDerechaP1", true);
  726. }
  727. }
  728.  
  729. if (this.keyboardP1.D.isDown === false && this.keyboardP1.A.isDown === false && this.keyboardP1.W.isDown === false) {
  730. if (this.playerU.body.velocity.x > 0) {
  731. this.playerU.anims.stop();
  732. this.playerU.anims.play("IdleDerechaP1", true);
  733. }
  734. if (this.playerU.body.velocity.x < 0) {
  735. this.playerU.anims.stop();
  736. this.playerU.anims.play("IdleIzquierdaP1", true);
  737. }
  738. this.playerU.body.setVelocityX(0);
  739. }
  740.  
  741. }
  742.  
  743.  
  744.  
  745. if (this.keyboardP2.ESC.isDown === true && this.keyLockP2 === false) {
  746. console.log("Iniciando pausa")
  747. this.keyLockP2 = true;
  748. this.keyboardP2.ESC.isDown = false;
  749. this.pararP1();
  750. this.pararP2();
  751. this.scene.launch("Pause", { escena: this, soundManager: this.soundManager })
  752. //this.keyboardP2.ESC.isDown=true;
  753. }
  754.  
  755.  
  756.  
  757.  
  758. }
  759.  
  760.  
  761. Prueba(player) {
  762.  
  763. let pos = (player.x + 1180) / 1180
  764. pos = Math.trunc(pos) - 1
  765. player.body.setVelocityX(0);
  766. player.body.setVelocityY(0);
  767. player.anims.stop();
  768.  
  769.  
  770. if (player.id == 0) {
  771. player.anims.play("IdleDerechaP1", true);
  772. this.PruebaP1(pos);
  773. } else {
  774. player.anims.play("IdleDerechaP2", true);
  775. this.PruebaP2(pos)
  776. }
  777. }
  778.  
  779. PruebaP1(code) {
  780. if (this.keyboardP1.E.isDown === true && !this.escenasActivas[0]) {
  781.  
  782. let p = 0;
  783. let e = 0;
  784.  
  785. for (let i = 0; i < this.escenarios.length; i++) {
  786. if (code === this.escenarios[i].pos) {
  787. p = this.escenarios[i].nombre
  788. e = i;
  789. }
  790.  
  791. }
  792.  
  793. if (this.escenarios[e].completadoP1U === false) {
  794. this.scene.launch(p + "P1", { escena: this, soundManager: this.soundManager });
  795. this.escenasActivas[0] = true;
  796. }
  797. if (this.escenarios[e].completadoP1U === true && this.escenarios[e].doble === true) {
  798. if (this.escenarios[e].completadoP1D === false) {
  799. console.log("INICIANDO PARTE 2")
  800. this.scene.launch(p + "P1V2", { escena: this, soundManager: this.soundManager });
  801. this.escenasActivas[0] = true;
  802. }
  803. }
  804.  
  805.  
  806. }
  807. }
  808. PruebaP2(code) {
  809. if (this.keyboardP2.SPACE.isDown === true && !this.escenasActivas[1]) {
  810. let p = 0;
  811. let e = 0;
  812. for (let i = 0; i < this.escenarios.length; i++) {
  813. if (code === this.escenarios[i].pos) {
  814. p = this.escenarios[i].nombre
  815. e = i;
  816. }
  817.  
  818. }
  819.  
  820.  
  821. if (this.escenarios[e].completadoP2U === false) {
  822. this.scene.launch(p + "P2", { escena: this, soundManager: this.soundManager });
  823. this.escenasActivas[1] = true;
  824.  
  825. }
  826. if (this.escenarios[e].completadoP2U === true && this.escenarios[e].doble === true) {
  827. if (this.escenarios[e].completadoP2D === false) {
  828. console.log("INICIANDO PARTE 2")
  829. this.scene.launch(p + "P2V2", { escena: this, soundManager: this.soundManager });
  830. this.escenasActivas[1] = true;
  831. }
  832. }
  833.  
  834.  
  835. }
  836.  
  837. }
  838.  
  839.  
  840.  
  841. teletransporte(player, factor, camara) {
  842.  
  843. if (this.keyboardP1.E.isDown === true) {
  844.  
  845. player.body.setVelocityX(0);
  846. player.body.setVelocityY(0);
  847. player.anims.stop();
  848. player.x = (1180 * (factor + 1) + 25);
  849.  
  850.  
  851. player.y = this.game.canvas.height / 2 - 50;
  852. camara.setBounds(0 + 1180 * (factor + 1), 0, this.game.canvas.width, this.game.canvas.height / 2)
  853.  
  854. //Sonido
  855. this.soundManager.play('TeletransporteFinal')
  856.  
  857. }
  858.  
  859. }
  860. teletransporteD(player, factor, camara) {
  861. if (this.keyboardP2.SPACE.isDown === true) {
  862. player.body.setVelocityX(0);
  863. player.body.setVelocityY(0);
  864. player.anims.stop();
  865. player.x = (1180 * (factor + 1) + 25);
  866.  
  867.  
  868. player.y = this.game.canvas.height - 50;
  869. camara.setBounds(0 + 1180 * (factor + 1), this.game.canvas.height / 2, this.game.canvas.width, this.game.canvas.height / 2)
  870. }
  871.  
  872. }
  873.  
  874.  
  875. //Funciones Cronometro
  876.  
  877. empezar() {
  878. if (this.playP1 === false) {
  879. let empP1 = new Date();
  880. this.elcronoP1 = setInterval(() => { this.tiempoP1(empP1) }, 10);
  881. this.playP1 = true; //Reloj puesta en marcha
  882. }
  883. if (this.playP2 === false) {
  884. let empP2 = new Date();
  885. this.elcronoP2 = setInterval(() => { this.tiempoP2(empP2) }, 10);
  886. this.playP2 = true;
  887. }
  888. }
  889.  
  890. tiempoP1(empP1) {
  891.  
  892. let actual = new Date();
  893. let cr = new Date();
  894.  
  895. //Player 1
  896. this.croP1 = actual - empP1;
  897. cr.setTime(this.croP1);
  898.  
  899. let timeP1 = cr.getTime() + this.playerU.time
  900. //Transformar
  901. let cs1 = timeP1 % 1000;
  902. cs1 = cs1 / 10;
  903. cs1 = Math.round(cs1);
  904. let sg1 = timeP1 / 1000
  905. //sg1 = sg1 % 100;
  906. sg1 = Math.trunc(sg1)
  907. let mn1 = timeP1 / 60000;
  908. mn1 = Math.trunc(mn1)
  909.  
  910.  
  911. if (cs1 < 10) {
  912. cs1 = "0" + cs1;
  913. }
  914.  
  915. if (sg1 > 59) {
  916. sg1 = sg1 % 60;
  917. //sg1 = "0" + sg1;
  918. }
  919.  
  920. if (sg1 < 10) {
  921. sg1 = "0" + sg1;
  922. }
  923. if (mn1 < 10) {
  924. mn1 = "0" + mn1;
  925. }
  926.  
  927.  
  928.  
  929.  
  930. // this.textoCronometro.setText([
  931. // 'Tiempo: ' + ho + " : " + mn + " : " + sg + " : " + cs
  932. // ]);
  933.  
  934. /*
  935. console.log(this.TiempoP2.x);
  936. this.TiempoP2.x=this.cam2.midPoint.x+350-216
  937. this.TiempoP2.y=this.cam2.midPoint.y-90+22,
  938. //*/
  939.  
  940. this.TiempoP1.setText([
  941. mn1 + " : " + sg1 + " : " + cs1
  942. ]);
  943.  
  944.  
  945.  
  946. }
  947.  
  948. tiempoP2(empP2) {
  949.  
  950. let actual = new Date();
  951. let cr = new Date();
  952. //Player 2
  953. this.croP2 = actual - empP2;
  954. cr.setTime(this.croP2);
  955.  
  956. let timeP2 = cr.getTime() + this.playerD.time;
  957. //Transformar
  958. let cs2 = timeP2 % 1000;
  959. cs2 = cs2 / 10;
  960. cs2 = Math.round(cs2);
  961. let sg2 = timeP2 / 1000
  962. //sg1 = sg1 % 100;
  963. sg2 = Math.trunc(sg2)
  964. let mn2 = timeP2 / 60000;
  965. mn2 = Math.trunc(mn2)
  966.  
  967. if (cs2 < 10) {
  968. cs2 = "0" + cs2;
  969. }
  970.  
  971. if (sg2 > 59) {
  972. sg2 = sg2 % 60;
  973. //sg2 = "0" + sg2;
  974. }
  975.  
  976. if (sg2 < 10) {
  977. sg2 = "0" + sg2;
  978. }
  979.  
  980.  
  981. if (mn2 < 10) {
  982. mn2 = "0" + mn2;
  983. }
  984.  
  985. this.TiempoP2.setText([
  986. mn2 + " : " + sg2 + " : " + cs2
  987. ]);
  988.  
  989. this.TiempoP2.setText([
  990. mn2 + " : " + sg2 + " : " + cs2
  991. ]);
  992.  
  993. this.TiempoP2.setText([
  994. mn2 + " : " + sg2 + " : " + cs2
  995. ]);
  996.  
  997. }
  998.  
  999.  
  1000.  
  1001. pararP1() {
  1002. if (this.end.player1 === false) {
  1003. if (this.playP1 === true) {
  1004. clearInterval(this.elcronoP1);
  1005. this.playP1 = false;
  1006. }
  1007. }
  1008. }
  1009.  
  1010. continuarP1() {
  1011. if (this.end.player1 === false) {
  1012. if (this.playP1 === false) {
  1013.  
  1014. let emp2 = new Date();
  1015. emp2 = emp2.getTime();
  1016.  
  1017. let emp3 = emp2 - this.croP1
  1018.  
  1019. let emp = new Date();
  1020. emp.setTime(emp3);
  1021. this.elcronoP1 = setInterval(() => { this.tiempoP1(emp) }, 10);
  1022. this.playP1 = true;
  1023. }
  1024. }
  1025. }
  1026.  
  1027. pararP2() {
  1028. if (this.end.player2 === false) {
  1029. if (this.playP2 === true) {
  1030. clearInterval(this.elcronoP2);
  1031. this.playP2 = false;
  1032. }
  1033. }
  1034. }
  1035.  
  1036. continuarP2() {
  1037.  
  1038. if (this.end.player2 === false) {
  1039. if (this.playP2 === false) {
  1040.  
  1041. let emp2 = new Date();
  1042. emp2 = emp2.getTime();
  1043.  
  1044. let emp3 = emp2 - this.croP1
  1045.  
  1046. let emp = new Date();
  1047. emp.setTime(emp3);
  1048. this.elcronoP2 = setInterval(() => { this.tiempoP2(emp) }, 10);
  1049. this.playP2 = true;
  1050. }
  1051. }
  1052. }
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058. //POWER UPS
  1059.  
  1060.  
  1061. crearSpeedUpP1(x, y, pos) {
  1062. let run = this.physics.add.image(x + 1180 * pos, y, "run").setOrigin(0, 0);
  1063. run.setScale(0.1)
  1064. this.physics.add.overlap(this.playerU, run, () => {
  1065. this.playerU.velocidad = 500
  1066. run.destroy();
  1067. setTimeout(() => { this.playerU.velocidad = 300; console.log("Se te acabo el chollo") }, 2000)
  1068. }, null, this);
  1069. }
  1070.  
  1071.  
  1072.  
  1073. crearMenosTP1(x, y, pos) {
  1074. let reloj = this.physics.add.image(x + 1180 * pos, y, "menosT").setOrigin(0, 0);
  1075. reloj.setScale(0.1)
  1076. this.physics.add.overlap(this.playerU, reloj, () => {
  1077. this.playerU.time += -3000;
  1078. reloj.destroy();
  1079. }, null, this);
  1080. }
  1081.  
  1082. crearMasTP1() {
  1083. this.playerD.time += 13000;
  1084. }
  1085.  
  1086. crearFrostP1() {
  1087. //let reloj = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 100, "menosT").setOrigin(0, 0);
  1088. //reloj.setScale(0.1)
  1089. //this.physics.add.overlap(this.playerU, reloj, () => {
  1090. this.playerD.setVelocityX(0);
  1091. this.escenasActivas[1] = true;
  1092. if (this.game.scene.isActive("CintaP2")) {
  1093. this.game.scene.stop("CintaP2");
  1094. this.blurGD.alpha = 0;
  1095. }
  1096. if (this.game.scene.isActive("CintaP2V2")) {
  1097. this.game.scene.stop("CintaP2V2");
  1098. this.blurGD.alpha = 0;
  1099. }
  1100. if (this.game.scene.isActive("ContadorP2")) {
  1101. this.game.scene.stop("ContadorP2");
  1102. this.escBU22.alpha = 0;
  1103. }
  1104. if (this.game.scene.isActive("ElectricidadP2")) {
  1105. this.game.scene.stop("ElectricidadP2");
  1106. this.blurElectricidadD.alpha = 0;
  1107. }
  1108. if (this.game.scene.isActive("ElectricidadP2V2")) {
  1109. this.game.scene.stop("ElectricidadP2V2");
  1110. this.blurElectricidadD.alpha = 0;
  1111. }
  1112. if (this.game.scene.isActive("LaboratorioP2")) {
  1113. this.game.scene.stop("LaboratorioP2");
  1114. this.blurLaboratorioD.alpha = 0;
  1115. }
  1116. setTimeout(() => { this.escenasActivas[1] = false; }, 6000)
  1117. //reloj.destroy();
  1118. //}, null, this);
  1119. }
  1120.  
  1121.  
  1122.  
  1123.  
  1124. crearBlindP1() {
  1125. //let blind = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 100, "menosT").setOrigin(0, 0);
  1126. //blind.setScale(0.1)
  1127. //this.physics.add.overlap(this.playerU, blind, () => {
  1128. let ceguera = this.add.image(this.game.canvas.width / 2, 197, "Foco")
  1129. ceguera.scale = 0.6;
  1130. ceguera.setScrollFactor(0, 0)
  1131. ceguera.setDepth(1000000)
  1132. this.cam1.ignore(ceguera);
  1133. //blind.destroy();
  1134. setTimeout(() => { ceguera.destroy(); console.log("Se te acabo la ceguera") }, 15000)
  1135.  
  1136. //}, null, this);
  1137. }
  1138.  
  1139. crearRayosP1() {
  1140. //let rayos = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 100, "menosT").setOrigin(0, 0);
  1141. //rayos.setScale(0.1)
  1142. let pos = (this.playerD.x + 1180) / 1180
  1143. pos = Math.trunc(pos) - 1
  1144. //this.physics.add.overlap(this.playerU, rayos, () => {
  1145. this.RayosD(0, pos);
  1146. // rayos.destroy();
  1147.  
  1148. //}, null, this);
  1149. }
  1150.  
  1151. RayosD(i, postion) {
  1152.  
  1153.  
  1154. if (i < 6) {
  1155. //Primero
  1156.  
  1157.  
  1158.  
  1159. let r1 = this.physics.add.image(this.game.canvas.width / 5 + 1180 * postion, this.game.canvas.height * 0.75, "laser")
  1160. r1.alpha = 0.95
  1161. r1.displayHeight = this.game.canvas.height / 2;
  1162.  
  1163. this.physics.add.overlap(this.playerD, r1, () => {
  1164. this.playerD.velocidad = 200;
  1165. console.log("se rompe");
  1166. r1.destroy();
  1167. }, null, this)
  1168.  
  1169.  
  1170. let r2 = this.physics.add.image(this.game.canvas.width / 5 * 2 + 1180 * postion, this.game.canvas.height * 0.75, "laser")
  1171. r2.alpha = 0.95
  1172. r2.displayHeight = this.game.canvas.height / 2;
  1173.  
  1174. this.physics.add.overlap(this.playerD, r2, () => {
  1175. this.playerD.velocidad = 200;
  1176. console.log("se rompe");
  1177. r2.destroy();
  1178. }, null, this)
  1179.  
  1180. let r3 = this.physics.add.image(this.game.canvas.width / 5 * 3 + 1180 * postion, this.game.canvas.height * 0.75, "laser")
  1181. r3.alpha = 0.95
  1182. r3.displayHeight = this.game.canvas.height / 2;
  1183.  
  1184. this.physics.add.overlap(this.playerD, r3, () => {
  1185. this.playerD.velocidad = 200;
  1186. console.log("se rompe");
  1187. r3.destroy();
  1188. }, null, this)
  1189.  
  1190.  
  1191. let r4 = this.physics.add.image(this.game.canvas.width / 5 * 4 + 1180 * postion, this.game.canvas.height * 0.75, "laser")
  1192. r4.alpha = 0.95
  1193. r4.displayHeight = this.game.canvas.height / 2;
  1194.  
  1195. this.physics.add.overlap(this.playerD, r4, () => {
  1196. this.playerD.velocidad = 200;
  1197. console.log("se rompe");
  1198. r4.destroy();
  1199. }, null, this)
  1200.  
  1201.  
  1202.  
  1203. setTimeout(() => {
  1204. if (r1 !== undefined) {
  1205. console.log("se rompe");
  1206. r1.destroy();
  1207. }
  1208. if (r2 !== undefined) {
  1209. console.log("se rompe");
  1210. r2.destroy();
  1211. }
  1212. if (r3 !== undefined) {
  1213. console.log("se rompe");
  1214. r3.destroy();
  1215. }
  1216. if (r4 !== undefined) {
  1217. console.log("se rompe");
  1218. r4.destroy();
  1219. }
  1220. this.playerD.velocidad = 300
  1221.  
  1222. }, 3000);
  1223.  
  1224.  
  1225.  
  1226.  
  1227. setTimeout(() => {
  1228. i++;
  1229. let postion = (this.playerD.x + 1180) / 1180
  1230. postion = Math.trunc(postion) - 1
  1231. this.RayosD(i, postion);
  1232.  
  1233. }, 3500);
  1234.  
  1235. }
  1236. }
  1237.  
  1238.  
  1239. crearSpeedUpP2(x, y, pos) {
  1240. let run = this.physics.add.image(x + 1180 * pos, y + this.game.canvas.height / 2, "run").setOrigin(0, 0);
  1241. run.setScale(0.1)
  1242. this.physics.add.overlap(this.playerD, run, () => {
  1243. this.playerD.velocidad = 500
  1244. run.destroy();
  1245. setTimeout(() => { this.playerD.velocidad = 300; console.log("Se te acabo el chollo") }, 2000)
  1246. }, null, this);
  1247. }
  1248.  
  1249.  
  1250. crearMenosTP2(x, y, pos) {
  1251. let reloj = this.physics.add.image(x + 1180 * pos, y + this.game.canvas.height / 2, "menosT").setOrigin(0, 0);
  1252. reloj.setScale(0.1)
  1253. this.physics.add.overlap(this.playerD, reloj, () => {
  1254. this.playerD.time += -3000;
  1255. reloj.destroy();
  1256. }, null, this);
  1257. }
  1258. crearMasTP2() {
  1259. /*let timePLUS=this.add.sprite(50 + 1180 * this.escenarios[1].pos, 100 + this.game.canvas.height / 2,"time++");
  1260. timePLUS.anims.play("timePlus");
  1261. timePLUS.setScale(0.1);*/
  1262. this.playerU.time += 13000;
  1263. }
  1264.  
  1265.  
  1266. crearBlindP2() {
  1267. //let blind = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 100 + this.game.canvas.height / 2, "menosT").setOrigin(0, 0);
  1268. //blind.setScale(0.1)
  1269. //this.physics.add.overlap(this.playerD, blind, () => {
  1270. let ceguera = this.add.image(this.game.canvas.width / 2, 197, "Foco")
  1271. ceguera.scale = 0.6;
  1272. ceguera.setScrollFactor(0, 0)
  1273. ceguera.setDepth(1000000)
  1274. this.cam2.ignore(ceguera);
  1275. //blind.destroy();
  1276. setTimeout(() => { ceguera.destroy(); console.log("Se te acabo la ceguera") }, 15000)
  1277.  
  1278. //}, null, this);
  1279. }
  1280.  
  1281. crearFrostP2() {
  1282. // let reloj = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 100 + this.game.canvas.height / 2, "menosT").setOrigin(0, 0);
  1283. //reloj.setScale(0.1)
  1284. //this.physics.add.overlap(this.playerD, reloj, () => {
  1285. this.playerU.setVelocityX(0);
  1286. this.escenasActivas[0] = true;
  1287. if (this.game.scene.isActive("CintaP1")) {
  1288. this.game.scene.stop("CintaP1");
  1289. this.blurGU.alpha = 0;
  1290. }
  1291. if (this.game.scene.isActive("CintaP1V2")) {
  1292. this.game.scene.stop("CintaP1V2");
  1293. this.blurGU.alpha = 0;
  1294. }
  1295. if (this.game.scene.isActive("ContadorP1")) {
  1296. this.game.scene.stop("ContadorP1");
  1297. this.escBU2.alpha = 0;
  1298. }
  1299. if (this.game.scene.isActive("ElectricidadP1")) {
  1300. this.game.scene.stop("ElectricidadP1");
  1301. this.blurElectricidadU.alpha = 0;
  1302. }
  1303. if (this.game.scene.isActive("ElectricidadP1V2")) {
  1304. this.game.scene.stop("ElectricidadP1V2");
  1305. this.blurElectricidadU.alpha = 0;
  1306. }
  1307. if (this.game.scene.isActive("LaboratorioP1")) {
  1308. this.game.scene.stop("LaboratorioP1");
  1309. this.blurLaboratorioU.alpha = 0;
  1310. }
  1311. setTimeout(() => { this.escenasActivas[0] = false; }, 6000)
  1312. // reloj.destroy();
  1313. //}, null, this);
  1314. }
  1315.  
  1316.  
  1317. crearRayosP2() {
  1318. //let rayos = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 100+this.game.canvas.height/2, "menosT").setOrigin(0, 0);
  1319. //rayos.setScale(0.1)
  1320. let pos = (this.playerU.x + 1180) / 1180
  1321. pos = Math.trunc(pos) - 1
  1322. //this.physics.add.overlap(this.playerD, rayos, () => {
  1323. this.RayosU(0, pos);
  1324. // rayos.destroy();
  1325.  
  1326. //}, null, this);
  1327. }
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333. RayosU(i, postion) {
  1334.  
  1335.  
  1336. if (i < 6) {
  1337. //Primero
  1338.  
  1339.  
  1340.  
  1341. let r1 = this.physics.add.image(this.game.canvas.width / 5 + 1180 * postion, this.game.canvas.height * 0.25, "laser")
  1342. r1.alpha = 0.95
  1343. r1.displayHeight = this.game.canvas.height / 2;
  1344.  
  1345. this.physics.add.overlap(this.playerU, r1, () => {
  1346. this.playerU.velocidad = 200;
  1347. console.log("se rompe");
  1348. r1.destroy();
  1349. }, null, this)
  1350.  
  1351.  
  1352. let r2 = this.physics.add.image(this.game.canvas.width / 5 * 2 + 1180 * postion, this.game.canvas.height * 0.25, "laser")
  1353. r2.alpha = 0.95
  1354. r2.displayHeight = this.game.canvas.height / 2;
  1355.  
  1356. this.physics.add.overlap(this.playerU, r2, () => {
  1357. this.playerU.velocidad = 200;
  1358. console.log("se rompe");
  1359. r2.destroy();
  1360. }, null, this)
  1361.  
  1362. let r3 = this.physics.add.image(this.game.canvas.width / 5 * 3 + 1180 * postion, this.game.canvas.height * 0.25, "laser")
  1363. r3.alpha = 0.95
  1364. r3.displayHeight = this.game.canvas.height / 2;
  1365.  
  1366. this.physics.add.overlap(this.playerU, r3, () => {
  1367. this.playerU.velocidad = 200;
  1368. console.log("se rompe");
  1369. r3.destroy();
  1370. }, null, this)
  1371.  
  1372.  
  1373. let r4 = this.physics.add.image(this.game.canvas.width / 5 * 4 + 1180 * postion, this.game.canvas.height * 0.25, "laser")
  1374. r4.alpha = 0.95
  1375. r4.displayHeight = this.game.canvas.height / 2;
  1376.  
  1377. this.physics.add.overlap(this.playerU, r4, () => {
  1378. this.playerU.velocidad = 200;
  1379. console.log("se rompe");
  1380. r4.destroy();
  1381. }, null, this)
  1382.  
  1383.  
  1384.  
  1385. setTimeout(() => {
  1386. if (r1 !== undefined) {
  1387. console.log("se rompe");
  1388. r1.destroy();
  1389. }
  1390. if (r2 !== undefined) {
  1391. console.log("se rompe");
  1392. r2.destroy();
  1393. }
  1394. if (r3 !== undefined) {
  1395. console.log("se rompe");
  1396. r3.destroy();
  1397. }
  1398. if (r4 !== undefined) {
  1399. console.log("se rompe");
  1400. r4.destroy();
  1401. }
  1402. this.playerU.velocidad = 300
  1403.  
  1404. }, 3000);
  1405.  
  1406.  
  1407.  
  1408.  
  1409. setTimeout(() => {
  1410. i++;
  1411. let postion = (this.playerU.x + 1180) / 1180
  1412. postion = Math.trunc(postion) - 1
  1413. this.RayosU(i, postion);
  1414.  
  1415. }, 3500);
  1416.  
  1417. }
  1418. }
  1419.  
  1420.  
  1421. //PORTALES
  1422.  
  1423.  
  1424. crearPortalGimnasioP1() {
  1425. let spritePortal = this.add.sprite(1038 + 1180 * this.escenarios[0].pos, this.game.canvas.height * 0.34, "portal");
  1426. spritePortal.play("portalAnim");
  1427. spritePortal.setScale(0.5);
  1428. this.portal = this.physics.add.image(1038 + 1180 * this.escenarios[0].pos, this.game.canvas.height * 0.34, "logo")
  1429. this.portal.displayHeight = 155; //spritePortal.height x 0.5
  1430. this.portal.displayWidth = 84; //spritePortal.width x 0.5
  1431. this.portal.alpha = 0;
  1432.  
  1433. //let pos = (player.x + 1180) / 1180
  1434. //pos = Math.trunc(pos) - 1
  1435.  
  1436.  
  1437. this.physics.add.overlap(this.playerU, this.portal, () => { this.teletransporte(this.playerU, this.escenarios[0].pos, this.cam1) }, null, this);
  1438.  
  1439. }
  1440.  
  1441. crearPortalPulsadorP1() {
  1442. let spritePortal = this.add.sprite(1038 + 1180 * this.escenarios[1].pos, this.game.canvas.height * 0.34, "portal");
  1443. spritePortal.play("portalAnim");
  1444. spritePortal.setScale(0.5);
  1445. this.portal = this.physics.add.image(1038 + 1180 * this.escenarios[1].pos, this.game.canvas.height * 0.34, "logo")
  1446. this.portal.displayHeight = 155; //spritePortal.height x 0.5
  1447. this.portal.displayWidth = 84; //spritePortal.width x 0.5
  1448. this.portal.alpha = 0;
  1449.  
  1450. this.physics.add.overlap(this.playerU, this.portal, () => { this.teletransporte(this.playerU, this.escenarios[1].pos, this.cam1) }, null, this);
  1451.  
  1452. }
  1453.  
  1454.  
  1455. crearPortalElectricidadP1() {
  1456. let spritePortal = this.add.sprite(1038 + 1180 * this.escenarios[3].pos, this.game.canvas.height * 0.34, "portal");
  1457. spritePortal.play("portalAnim");
  1458. spritePortal.setScale(0.5);
  1459. this.portal = this.physics.add.image(1038 + 1180 * this.escenarios[3].pos, this.game.canvas.height * 0.34, "logo")
  1460. this.portal.displayHeight = 155;
  1461. this.portal.displayWidth = 84;
  1462. this.portal.alpha = 0;
  1463.  
  1464. this.physics.add.overlap(this.playerU, this.portal, () => { this.teletransporte(this.playerU, this.escenarios[3].pos, this.cam1) }, null, this);
  1465.  
  1466. }
  1467.  
  1468. crearPortalLaboratorioP1() {
  1469. let spritePortal = this.add.sprite(1038 + 1180 * this.escenarios[4].pos, this.game.canvas.height * 0.34, "portal");
  1470. spritePortal.play("portalAnim");
  1471. spritePortal.setScale(0.5);
  1472. this.portal = this.physics.add.image(1038 + 1180 * this.escenarios[4].pos, this.game.canvas.height * 0.34, "logo")
  1473. this.portal.displayHeight = 155; //spritePortal.height x 0.5
  1474. this.portal.displayWidth = 84; //spritePortal.width x 0.5
  1475. this.portal.alpha = 0;
  1476.  
  1477. //let pos = (player.x + 1180) / 1180
  1478. //pos = Math.trunc(pos) - 1
  1479.  
  1480.  
  1481. this.physics.add.overlap(this.playerU, this.portal, () => { this.teletransporte(this.playerU, this.escenarios[4].pos, this.cam1) }, null, this);
  1482.  
  1483. }
  1484.  
  1485.  
  1486.  
  1487.  
  1488. crearPortalGimnasioP2() {
  1489. let spritePortal2 = this.add.sprite(1038 + 1180 * this.escenarios[0].pos, this.game.canvas.height * 0.84, "portal");
  1490. spritePortal2.play("portalAnim");
  1491. spritePortal2.setScale(0.5);
  1492. this.portalD = this.physics.add.image(1038 + 1180 * this.escenarios[0].pos, this.game.canvas.height * 0.84, "logo")
  1493. this.portalD.displayHeight = 155; //spritePortal.height x 0.5
  1494. this.portalD.displayWidth = 84; //spritePortal.width x 0.5
  1495. this.portalD.alpha = 0;
  1496. this.physics.add.overlap(this.playerD, this.portalD, () => { this.teletransporteD(this.playerD, this.escenarios[0].pos, this.cam2) }, null, this); console.log(this.portal)
  1497. }
  1498.  
  1499.  
  1500. crearPortalPulsadorP2() {
  1501. let spritePortal2 = this.add.sprite(1038 + 1180 * this.escenarios[1].pos, this.game.canvas.height * 0.84, "portal");
  1502. spritePortal2.play("portalAnim");
  1503. spritePortal2.setScale(0.5);
  1504. this.portalD = this.physics.add.image(1038 + 1180 * this.escenarios[1].pos, this.game.canvas.height * 0.84, "logo")
  1505. this.portalD.displayHeight = 155; //spritePortal.height x 0.5
  1506. this.portalD.displayWidth = 84; //spritePortal.width x 0.5
  1507. this.portalD.alpha = 0;
  1508. this.physics.add.overlap(this.playerD, this.portalD, () => { this.teletransporteD(this.playerD, this.escenarios[1].pos, this.cam2) }, null, this); console.log(this.portal);
  1509. }
  1510.  
  1511.  
  1512. crearPortalElectricidadP2() {
  1513. let spritePortal = this.add.sprite(1038 + 1180 * this.escenarios[3].pos, this.game.canvas.height * 0.84, "portal");
  1514. spritePortal.play("portalAnim");
  1515. spritePortal.setScale(0.5);
  1516. this.portalD = this.physics.add.image(1038 + 1180 * this.escenarios[3].pos, this.game.canvas.height * 0.84, "logo")
  1517. this.portalD.displayHeight = 155;
  1518. this.portalD.displayWidth = 84;
  1519. this.portalD.alpha = 0;
  1520. this.physics.add.overlap(this.playerD, this.portalD, () => { this.teletransporteD(this.playerD, this.escenarios[3].pos, this.cam2) }, null, this); console.log(this.portal)
  1521. }
  1522.  
  1523.  
  1524. crearPortalLaboratorioP2() {
  1525. let spritePortal2 = this.add.sprite(1038 + 1180 * this.escenarios[4].pos, this.game.canvas.height * 0.84, "portal");
  1526. spritePortal2.play("portalAnim");
  1527. spritePortal2.setScale(0.5);
  1528. this.portalD = this.physics.add.image(1038 + 1180 * this.escenarios[4].pos, this.game.canvas.height * 0.84, "logo")
  1529. this.portalD.displayHeight = 155; //spritePortal.height x 0.5
  1530. this.portalD.displayWidth = 84; //spritePortal.width x 0.5
  1531. this.portalD.alpha = 0;
  1532. this.physics.add.overlap(this.playerD, this.portalD, () => { this.teletransporteD(this.playerD, this.escenarios[4].pos, this.cam2) }, null, this); console.log(this.portal)
  1533. }
  1534.  
  1535. //plataformas
  1536.  
  1537.  
  1538.  
  1539. crearPlataformasGimnasioP1() {
  1540. let p1_1_1 = this.physics.add.image(100 + 1180 * this.escenarios[0].pos, this.game.canvas.height * 0.42, "gymplatform").setImmovable(true);
  1541. p1_1_1.displayHeight = 20;
  1542. p1_1_1.displayWidth = 80;
  1543.  
  1544. let p1_1_2 = this.physics.add.image(220 + 1180 * this.escenarios[0].pos, 260, "gymplatform").setImmovable(true);
  1545. p1_1_2.displayHeight = 20;
  1546. p1_1_2.displayWidth = 80;
  1547.  
  1548. let p1_1_3 = this.physics.add.image(320 + 1180 * this.escenarios[0].pos, 150, "gymplatform").setImmovable(true);
  1549. this.tweens.timeline({
  1550. targets: p1_1_3.body.velocity,
  1551. loop: -1,
  1552. tweens: [
  1553. { y: 80, duration: 750, ease: 'Stepped' },
  1554. { y: -80, duration: 750, ease: 'Stepped' }
  1555. ]
  1556. })
  1557.  
  1558. let p1_1_4 = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 120, "gymplatform").setImmovable(true);
  1559. p1_1_4.displayHeight = 20;
  1560. p1_1_4.displayWidth = 80;
  1561.  
  1562. let p1_1_5 = this.physics.add.image(85 + 1180 * this.escenarios[0].pos, 150, "gymplatform").setImmovable(true);
  1563. p1_1_5.displayHeight = 20;
  1564. p1_1_5.displayWidth = 80;
  1565.  
  1566. let p1_1_6 = this.physics.add.image(430 + 1180 * this.escenarios[0].pos, 185, "gymplatform").setImmovable(true);
  1567. p1_1_6.displayHeight = 20;
  1568. p1_1_6.displayWidth = 80;
  1569.  
  1570. let p1_1_7 = this.physics.add.image(535 + 1180 * this.escenarios[0].pos, 230, "gymplatform").setImmovable(true);
  1571. p1_1_7.displayHeight = 20;
  1572. p1_1_7.displayWidth = 80;
  1573.  
  1574. let p1_1_8 = this.physics.add.image(650 + 1180 * this.escenarios[0].pos, 230, "gymplatform").setImmovable(true);
  1575. p1_1_8.displayHeight = 20;
  1576. p1_1_8.displayWidth = 80;
  1577.  
  1578. this.tweens.timeline({
  1579. targets: p1_1_8.body.velocity,
  1580. loop: -1,
  1581. tweens: [
  1582. { y: -60, duration: 850, ease: 'Stepped' },
  1583. { y: 60, duration: 850, ease: 'Stepped' }
  1584. ]
  1585. })
  1586.  
  1587. let p1_1_9 = this.physics.add.image(750 + 1180 * this.escenarios[0].pos, 135, "gymplatform").setImmovable(true);
  1588. p1_1_9.displayHeight = 20;
  1589. p1_1_9.displayWidth = 80;
  1590.  
  1591. let p1_1_10 = this.physics.add.image(950 + 1180 * this.escenarios[0].pos, 190, "gymplatform").setImmovable(true);
  1592. p1_1_10.displayHeight = 20;
  1593. p1_1_10.displayWidth = 80;
  1594.  
  1595. this.tweens.timeline({
  1596. targets: p1_1_10.body.velocity,
  1597. loop: -1,
  1598. tweens: [
  1599. { x: -60, duration: 1700, ease: 'Stepped' },
  1600. { x: 60, duration: 1700, ease: 'Stepped' }
  1601. ]
  1602. })
  1603.  
  1604. let p1_1_11 = this.physics.add.image(1020 + 1180 * this.escenarios[0].pos, 135, "gymplatform").setImmovable(true);
  1605. p1_1_11.displayHeight = 20;
  1606. p1_1_11.displayWidth = 80;
  1607.  
  1608.  
  1609. let grupoP1_gym = this.add.group();
  1610. grupoP1_gym.add(p1_1_1);
  1611. grupoP1_gym.add(p1_1_2);
  1612. grupoP1_gym.add(p1_1_3);
  1613. grupoP1_gym.add(p1_1_4);
  1614. grupoP1_gym.add(p1_1_5);
  1615. grupoP1_gym.add(p1_1_6);
  1616. grupoP1_gym.add(p1_1_7);
  1617. grupoP1_gym.add(p1_1_8);
  1618. grupoP1_gym.add(p1_1_9);
  1619. grupoP1_gym.add(p1_1_10);
  1620. grupoP1_gym.add(p1_1_11);
  1621.  
  1622. this.physics.add.collider(this.playerU, grupoP1_gym);
  1623.  
  1624. }
  1625.  
  1626. crearPlataformasGimnasioP2() {
  1627. let p2_1_1 = this.physics.add.image(100 + 1180 * this.escenarios[0].pos, this.game.canvas.height * 0.42 + 360, "gymplatform").setImmovable(true);
  1628. p2_1_1.displayHeight = 20;
  1629. p2_1_1.displayWidth = 80;
  1630.  
  1631. let p2_1_2 = this.physics.add.image(220 + 1180 * this.escenarios[0].pos, 620, "gymplatform").setImmovable(true);
  1632. p2_1_2.displayHeight = 20;
  1633. p2_1_2.displayWidth = 80;
  1634.  
  1635. let p2_1_3 = this.physics.add.image(320 + 1180 * this.escenarios[0].pos, 510, "gymplatform").setImmovable(true);
  1636. this.tweens.timeline({
  1637. targets: p2_1_3.body.velocity,
  1638. loop: -1,
  1639. tweens: [
  1640. { y: 80, duration: 750, ease: 'Stepped' },
  1641. { y: -80, duration: 750, ease: 'Stepped' }
  1642. ]
  1643. })
  1644.  
  1645. let p2_1_4 = this.physics.add.image(200 + 1180 * this.escenarios[0].pos, 480, "gymplatform").setImmovable(true);
  1646. p2_1_4.displayHeight = 20;
  1647. p2_1_4.displayWidth = 80;
  1648.  
  1649. let p2_1_5 = this.physics.add.image(85 + 1180 * this.escenarios[0].pos, 510, "gymplatform").setImmovable(true);
  1650. p2_1_5.displayHeight = 20;
  1651. p2_1_5.displayWidth = 80;
  1652.  
  1653. let p2_1_6 = this.physics.add.image(430 + 1180 * this.escenarios[0].pos, 545, "gymplatform").setImmovable(true);
  1654. p2_1_6.displayHeight = 20;
  1655. p2_1_6.displayWidth = 80;
  1656.  
  1657. let p2_1_7 = this.physics.add.image(535 + 1180 * this.escenarios[0].pos, 590, "gymplatform").setImmovable(true);
  1658. p2_1_7.displayHeight = 20;
  1659. p2_1_7.displayWidth = 80;
  1660.  
  1661. let p2_1_8 = this.physics.add.image(650 + 1180 * this.escenarios[0].pos, 590, "gymplatform").setImmovable(true);
  1662. p2_1_8.displayHeight = 20;
  1663. p2_1_8.displayWidth = 80;
  1664.  
  1665. this.tweens.timeline({
  1666. targets: p2_1_8.body.velocity,
  1667. loop: -1,
  1668. tweens: [
  1669. { y: -60, duration: 850, ease: 'Stepped' },
  1670. { y: 60, duration: 850, ease: 'Stepped' }
  1671. ]
  1672. })
  1673.  
  1674. let p2_1_9 = this.physics.add.image(750 + 1180 * this.escenarios[0].pos, 495, "gymplatform").setImmovable(true);
  1675. p2_1_9.displayHeight = 20;
  1676. p2_1_9.displayWidth = 80;
  1677.  
  1678. let p2_1_10 = this.physics.add.image(950 + 1180 * this.escenarios[0].pos, 550, "gymplatform").setImmovable(true);
  1679. p2_1_10.displayHeight = 20;
  1680. p2_1_10.displayWidth = 80;
  1681.  
  1682. this.tweens.timeline({
  1683. targets: p2_1_10.body.velocity,
  1684. loop: -1,
  1685. tweens: [
  1686. { x: -60, duration: 1700, ease: 'Stepped' },
  1687. { x: 60, duration: 1700, ease: 'Stepped' }
  1688. ]
  1689. })
  1690.  
  1691. let p2_1_11 = this.physics.add.image(1020 + 1180 * this.escenarios[0].pos, 495, "gymplatform").setImmovable(true);
  1692. p2_1_11.displayHeight = 20;
  1693. p2_1_11.displayWidth = 80;
  1694.  
  1695.  
  1696. let grupoP2_gym = this.add.group();
  1697. grupoP2_gym.add(p2_1_1);
  1698. grupoP2_gym.add(p2_1_2);
  1699. grupoP2_gym.add(p2_1_3);
  1700. grupoP2_gym.add(p2_1_4);
  1701. grupoP2_gym.add(p2_1_5);
  1702. grupoP2_gym.add(p2_1_6);
  1703. grupoP2_gym.add(p2_1_7);
  1704. grupoP2_gym.add(p2_1_8);
  1705. grupoP2_gym.add(p2_1_9);
  1706. grupoP2_gym.add(p2_1_10);
  1707. grupoP2_gym.add(p2_1_11);
  1708.  
  1709. this.physics.add.collider(this.playerD, grupoP2_gym);
  1710.  
  1711. }
  1712.  
  1713. crearPlataformasContador1() {
  1714. let p1_2_1 = this.physics.add.image(100 + 1180 * this.escenarios[1].pos, this.game.canvas.height * 0.42, "contplatform").setImmovable(true);
  1715. p1_2_1.displayHeight = 20;
  1716. p1_2_1.displayWidth = 80;
  1717.  
  1718. this.tweens.timeline({
  1719. targets: p1_2_1.body.velocity,
  1720. loop: -1,
  1721. tweens: [
  1722. { x: 60, duration: 2000, ease: 'Stepped' },
  1723. { x: -60, duration: 2000, ease: 'Stepped' }
  1724.  
  1725. ]
  1726. });
  1727.  
  1728. let p1_2_2 = this.physics.add.image(275 + 1180 * this.escenarios[1].pos, 220, "contplatform").setImmovable(true);
  1729. p1_2_2.displayHeight = 20;
  1730. p1_2_2.displayWidth = 80;
  1731.  
  1732. this.tweens.timeline({
  1733. targets: p1_2_2.body.velocity,
  1734. loop: -1,
  1735. tweens: [
  1736. { x: -80, duration: 1300, ease: 'Stepped' },
  1737. { x: 80, duration: 1300, ease: 'Stepped' }
  1738.  
  1739. ]
  1740. });
  1741.  
  1742. let p1_2_3 = this.physics.add.image(75 + 1180 * this.escenarios[1].pos, 150, "contplatform").setImmovable(true);
  1743. p1_2_3.displayHeight = 20;
  1744. p1_2_3.displayWidth = 80;
  1745.  
  1746. let p1_2_4 = this.physics.add.image(200 + 1180 * this.escenarios[1].pos, 100, "contplatform").setImmovable(true);
  1747. p1_2_4.displayHeight = 20;
  1748. p1_2_4.displayWidth = 80;
  1749.  
  1750. this.tweens.timeline({
  1751. targets: p1_2_4.body.velocity,
  1752. loop: -1,
  1753. tweens: [
  1754. { x: 70, duration: 1500, ease: 'Stepped' },
  1755. { x: -70, duration: 1500, ease: 'Stepped' }
  1756.  
  1757. ]
  1758. });
  1759.  
  1760. let p1_2_5 = this.physics.add.image(390 + 1180 * this.escenarios[1].pos, 100, "contplatform").setImmovable(true);
  1761. p1_2_5.displayHeight = 20;
  1762. p1_2_5.displayWidth = 80;
  1763.  
  1764. let p1_2_6 = this.physics.add.image(490 + 1180 * this.escenarios[1].pos, 100, "contplatform").setImmovable(true);
  1765. p1_2_6.displayHeight = 20;
  1766. p1_2_6.displayWidth = 80;
  1767.  
  1768. this.tweens.timeline({
  1769. targets: p1_2_6.body.velocity,
  1770. loop: -1,
  1771. tweens: [
  1772. { y: 40, duration: 2500, ease: 'Stepped' },
  1773. { y: -40, duration: 2500, ease: 'Stepped' }
  1774.  
  1775. ]
  1776. });
  1777.  
  1778. let p1_2_7 = this.physics.add.image(610 + 1180 * this.escenarios[1].pos, 200, "contplatform").setImmovable(true);
  1779. p1_2_7.displayHeight = 20;
  1780. p1_2_7.displayWidth = 80;
  1781.  
  1782. //muro para que no se entre en contador directamente
  1783. let notCheating = this.physics.add.image(790 + 1180 * this.escenarios[1].pos, 235, "telon").setImmovable(true);
  1784. notCheating.displayHeight = 250;
  1785. notCheating.displayWidth = 20;
  1786.  
  1787. let p1_2_8 = this.physics.add.image(720 + 1180 * this.escenarios[1].pos, 150, "contplatform").setImmovable(true);
  1788. p1_2_8.displayHeight = 20;
  1789. p1_2_8.displayWidth = 80;
  1790.  
  1791. let sueloPrueba = this.physics.add.image(932 + 1180 * this.escenarios[1].pos, 337, "gymplatform").setImmovable(true);
  1792. sueloPrueba.displayHeight = 43
  1793. sueloPrueba.displayWidth = 290
  1794. sueloPrueba.alpha = 0;
  1795.  
  1796.  
  1797. let grupoP1_cont = this.add.group();
  1798. grupoP1_cont.add(p1_2_1);
  1799. grupoP1_cont.add(p1_2_2);
  1800. grupoP1_cont.add(p1_2_3);
  1801. //plataforma 3 desaparece
  1802. var intermitence = setInterval(() => {
  1803. p1_2_3.alpha = p1_2_3.alpha == 1 ? 0 : 1;
  1804. p1_2_3.alpha == 1 ? grupoP1_cont.add(p1_2_3) : grupoP1_cont.remove(p1_2_3);
  1805. }, 2500);
  1806. grupoP1_cont.add(p1_2_4);
  1807. grupoP1_cont.add(p1_2_5);
  1808. grupoP1_cont.add(p1_2_6);
  1809. grupoP1_cont.add(p1_2_7);
  1810. grupoP1_cont.add(sueloPrueba);
  1811. var intermitence = setInterval(() => {
  1812. p1_2_7.alpha = p1_2_7.alpha == 1 ? 0 : 1;
  1813. p1_2_7.alpha == 1 ? grupoP1_cont.add(p1_2_7) : grupoP1_cont.remove(p1_2_7);
  1814. }, 2000);
  1815. grupoP1_cont.add(notCheating); //descomentar, solo está comentado para hacer pruebas rápidamente
  1816. grupoP1_cont.add(p1_2_8);
  1817.  
  1818. this.physics.add.collider(this.playerU, grupoP1_cont);
  1819.  
  1820. }
  1821. crearPlataformasContador2() {
  1822. let p2_2_1 = this.physics.add.image(100 + 1180 * this.escenarios[1].pos, this.game.canvas.height * 0.42 + 360, "contplatform").setImmovable(true);
  1823. p2_2_1.displayHeight = 20;
  1824. p2_2_1.displayWidth = 80;
  1825.  
  1826.  
  1827. this.tweens.timeline({
  1828. targets: p2_2_1.body.velocity,
  1829. loop: -1,
  1830. tweens: [
  1831. { x: 60, duration: 2000, ease: 'Stepped' },
  1832. { x: -60, duration: 2000, ease: 'Stepped' }
  1833.  
  1834. ]
  1835. });
  1836.  
  1837. let p2_2_2 = this.physics.add.image(275 + 1180 * this.escenarios[1].pos, 580, "contplatform").setImmovable(true);
  1838. p2_2_2.displayHeight = 20;
  1839. p2_2_2.displayWidth = 80;
  1840.  
  1841.  
  1842. this.tweens.timeline({
  1843. targets: p2_2_2.body.velocity,
  1844. loop: -1,
  1845. tweens: [
  1846. { x: -80, duration: 1200, ease: 'Stepped' },
  1847. { x: 80, duration: 1200, ease: 'Stepped' }
  1848.  
  1849. ]
  1850. });
  1851.  
  1852. let p2_2_3 = this.physics.add.image(75 + 1180 * this.escenarios[1].pos, 510, "contplatform").setImmovable(true);
  1853. p2_2_3.displayHeight = 20;
  1854. p2_2_3.displayWidth = 80;
  1855.  
  1856. let p2_2_4 = this.physics.add.image(200 + 1180 * this.escenarios[1].pos, 460, "contplatform").setImmovable(true);
  1857. p2_2_4.displayHeight = 20;
  1858. p2_2_4.displayWidth = 80;
  1859.  
  1860. this.tweens.timeline({
  1861. targets: p2_2_4.body.velocity,
  1862. loop: -1,
  1863. tweens: [
  1864. { x: 70, duration: 1500, ease: 'Stepped' },
  1865. { x: -70, duration: 1500, ease: 'Stepped' }
  1866.  
  1867. ]
  1868. });
  1869.  
  1870. let p2_2_5 = this.physics.add.image(390 + 1180 * this.escenarios[1].pos, 460, "contplatform").setImmovable(true);
  1871. p2_2_5.displayHeight = 20;
  1872. p2_2_5.displayWidth = 80;
  1873.  
  1874. let p2_2_6 = this.physics.add.image(490 + 1180 * this.escenarios[1].pos, 460, "contplatform").setImmovable(true);
  1875. p2_2_6.displayHeight = 20;
  1876. p2_2_6.displayWidth = 80;
  1877.  
  1878. this.tweens.timeline({
  1879. targets: p2_2_6.body.velocity,
  1880. loop: -1,
  1881. tweens: [
  1882. { y: 40, duration: 2500, ease: 'Stepped' },
  1883. { y: -40, duration: 2500, ease: 'Stepped' }
  1884.  
  1885. ]
  1886. });
  1887.  
  1888. let p2_2_7 = this.physics.add.image(610 + 1180 * this.escenarios[1].pos, 560, "contplatform").setImmovable(true);
  1889. p2_2_7.displayHeight = 20;
  1890. p2_2_7.displayWidth = 80;
  1891.  
  1892. //muro para que no se entre en contador directamente
  1893. let notCheating2 = this.physics.add.image(790 + 1180 * this.escenarios[1].pos, 595, "telon").setImmovable(true);
  1894. notCheating2.displayHeight = 250;
  1895. notCheating2.displayWidth = 20;
  1896.  
  1897.  
  1898. let p2_2_8 = this.physics.add.image(720 + 1180 * this.escenarios[1].pos, 510, "contplatform").setImmovable(true);
  1899. p2_2_8.displayHeight = 20;
  1900. p2_2_8.displayWidth = 80;
  1901.  
  1902. let sueloPrueba = this.physics.add.image(932 + 1180 * this.escenarios[1].pos, 337 + this.game.canvas.height / 2, "gymplatform").setImmovable(true);
  1903. sueloPrueba.displayHeight = 43
  1904. sueloPrueba.displayWidth = 290
  1905. sueloPrueba.alpha = 0;
  1906.  
  1907.  
  1908.  
  1909.  
  1910. let grupoP2_cont = this.add.group();
  1911. grupoP2_cont.add(p2_2_1);
  1912. grupoP2_cont.add(p2_2_2);
  1913. grupoP2_cont.add(p2_2_3);
  1914. //plataforma 3 desaparece
  1915. var intermitence = setInterval(() => {
  1916. p2_2_3.alpha = p2_2_3.alpha == 1 ? 0 : 1;
  1917. p2_2_3.alpha == 1 ? grupoP2_cont.add(p2_2_3) : grupoP2_cont.remove(p2_2_3);
  1918. }, 2500);
  1919.  
  1920. grupoP2_cont.add(p2_2_4);
  1921. grupoP2_cont.add(p2_2_5);
  1922. grupoP2_cont.add(p2_2_6);
  1923. grupoP2_cont.add(p2_2_7);
  1924.  
  1925. var intermitence = setInterval(() => {
  1926. p2_2_7.alpha = p2_2_7.alpha == 1 ? 0 : 1;
  1927. p2_2_7.alpha == 1 ? grupoP2_cont.add(p2_2_7) : grupoP2_cont.remove(p2_2_7);
  1928. }, 2000);
  1929.  
  1930. grupoP2_cont.add(notCheating2);
  1931. grupoP2_cont.add(p2_2_8);
  1932. grupoP2_cont.add(sueloPrueba);
  1933.  
  1934.  
  1935. this.physics.add.collider(this.playerD, grupoP2_cont);
  1936.  
  1937.  
  1938. }
  1939.  
  1940. crearPlataformasElectricidad1(that) {
  1941. var that_ = that;
  1942.  
  1943. let p1_3_1 = this.physics.add.image(108 + 1180 * this.escenarios[3].pos, 300, "elecplatform").setImmovable(true);
  1944. p1_3_1.displayHeight = 20;
  1945. p1_3_1.displayWidth = 80;
  1946.  
  1947. let p1_3_2 = this.physics.add.image(290 + 1180 * this.escenarios[3].pos, 180, "elecplatform").setImmovable(true);
  1948. p1_3_2.displayHeight = 20;
  1949. p1_3_2.displayWidth = 80;
  1950.  
  1951. this.tweens.timeline({
  1952. targets: p1_3_2.body.velocity,
  1953. loop: -1,
  1954. tweens: [
  1955. { x: -30, y: 30, duration: 2200, ease: 'Stepped' },
  1956. { x: 30, y: -30, duration: 2200, ease: 'Stepped' }
  1957.  
  1958. ]
  1959. });
  1960.  
  1961. let p1_3_3 = this.physics.add.image(190 + 1180 * this.escenarios[3].pos, 180, "elecplatform").setImmovable(true);
  1962. p1_3_3.displayHeight = 20;
  1963. p1_3_3.displayWidth = 80;
  1964.  
  1965. this.tweens.timeline({
  1966. targets: p1_3_3.body.velocity,
  1967. loop: -1,
  1968. tweens: [
  1969. { x: -30, y: -30, duration: 2200, ease: 'Stepped' },
  1970. { x: 30, y: 30, duration: 2200, ease: 'Stepped' }
  1971.  
  1972. ]
  1973. });
  1974.  
  1975. let p1_3_4 = this.physics.add.image(40 + 1180 * this.escenarios[3].pos, 115, "elecplatform").setImmovable(true);
  1976. p1_3_4.displayHeight = 20;
  1977. p1_3_4.displayWidth = 80;
  1978.  
  1979. //let p1_3_5=this.physics.add.image( 500 ,115, "gymplatform").setImmovable(true);
  1980.  
  1981. let p1_3_5 = this.physics.add.image(500 + 1180 * this.escenarios[3].pos, 200, "elecplatform").setImmovable(true).setVelocity(0, 100);
  1982. p1_3_5.displayHeight = 20;
  1983. p1_3_5.displayWidth = 80;
  1984.  
  1985. this.tweens.timeline({
  1986.  
  1987. targets: p1_3_5.body.velocity,
  1988. loop: -1,
  1989. duration: 1000,
  1990.  
  1991. tweens: [
  1992. { x: { value: -100, ease: 'Sine.easeOut' }, y: { value: 0, ease: 'Sine.easeIn' } },
  1993. { x: { value: 0, ease: 'Sine.easeIn' }, y: { value: -100, ease: 'Sine.easeOut' } },
  1994. { x: { value: 100, ease: 'Sine.easeOut' }, y: { value: 0, ease: 'Sine.easeIn' } },
  1995. { x: { value: 0, ease: 'Sine.easeIn' }, y: { value: 100, ease: 'Sine.easeOut' } },
  1996.  
  1997. ],
  1998. onLoop: function () {
  1999. p1_3_5.body.reset(500 + 1180 * that_.escenarios[3].pos, 200);
  2000. }
  2001. });
  2002.  
  2003. let p1_3_6 = this.physics.add.image(600 + 1180 * this.escenarios[3].pos, 150, "elecplatform").setImmovable(true);
  2004. p1_3_6.displayHeight = 20;
  2005. p1_3_6.displayWidth = 80;
  2006.  
  2007. let p1_3_7 = this.physics.add.image(840 + 1180 * this.escenarios[3].pos, 250, "elecplatform").setImmovable(true);
  2008. p1_3_7.displayHeight = 20;
  2009. p1_3_7.displayWidth = 220;
  2010.  
  2011.  
  2012. let grupoP1_elec = this.add.group();
  2013. grupoP1_elec.add(p1_3_1);
  2014. var intermitence = setInterval(() => {
  2015. p1_3_1.alpha = p1_3_1.alpha == 1 ? 0 : 1;
  2016. p1_3_1.alpha == 1 ? grupoP1_elec.add(p1_3_1) : grupoP1_elec.remove(p1_3_1);
  2017. }, 1000);
  2018. grupoP1_elec.add(p1_3_2);
  2019. grupoP1_elec.add(p1_3_3);
  2020. grupoP1_elec.add(p1_3_4);
  2021. grupoP1_elec.add(p1_3_5);
  2022. grupoP1_elec.add(p1_3_6);
  2023. var intermitence = setInterval(() => {
  2024. p1_3_6.alpha = p1_3_6.alpha == 1 ? 0 : 1;
  2025. p1_3_6.alpha == 1 ? grupoP1_elec.add(p1_3_6) : grupoP1_elec.remove(p1_3_6);
  2026. }, 1500);
  2027. grupoP1_elec.add(p1_3_7);
  2028.  
  2029.  
  2030. //Colisión plataformas electricidad
  2031. this.physics.add.collider(this.playerU, grupoP1_elec);
  2032. }
  2033.  
  2034. crearPlataformasElectricidad2(that) {
  2035. var that_ = that;
  2036.  
  2037. let p2_3_1 = this.physics.add.image(108 + 1180 * this.escenarios[3].pos, 660, "elecplatform").setImmovable(true);
  2038. p2_3_1.displayHeight = 20;
  2039. p2_3_1.displayWidth = 80;
  2040.  
  2041.  
  2042.  
  2043. let p2_3_2 = this.physics.add.image(290 + 1180 * this.escenarios[3].pos, 540, "elecplatform").setImmovable(true);
  2044. p2_3_2.displayHeight = 20;
  2045. p2_3_2.displayWidth = 80;
  2046.  
  2047. this.tweens.timeline({
  2048. targets: p2_3_2.body.velocity,
  2049. loop: -1,
  2050. tweens: [
  2051. { x: -30, y: 30, duration: 2200, ease: 'Stepped' },
  2052. { x: 30, y: -30, duration: 2200, ease: 'Stepped' }
  2053.  
  2054. ]
  2055. });
  2056.  
  2057. let p2_3_3 = this.physics.add.image(190 + 1180 * this.escenarios[3].pos, 540, "elecplatform").setImmovable(true);
  2058. p2_3_3.displayHeight = 20;
  2059. p2_3_3.displayWidth = 80;
  2060.  
  2061. this.tweens.timeline({
  2062. targets: p2_3_3.body.velocity,
  2063. loop: -1,
  2064. tweens: [
  2065. { x: -30, y: -30, duration: 2200, ease: 'Stepped' },
  2066. { x: 30, y: 30, duration: 2200, ease: 'Stepped' }
  2067.  
  2068. ]
  2069. });
  2070.  
  2071. let p2_3_4 = this.physics.add.image(40 + 1180 * this.escenarios[3].pos, 475, "elecplatform").setImmovable(true);
  2072. p2_3_4.displayHeight = 20;
  2073. p2_3_4.displayWidth = 80;
  2074.  
  2075. //let p1_3_5=this.physics.add.image( 500 ,115, "gymplatform").setImmovable(true);
  2076.  
  2077. let p2_3_5 = this.physics.add.image(500 + 1180 * this.escenarios[3].pos, 560, "elecplatform").setImmovable(true).setVelocity(0, 100);
  2078. p2_3_5.displayHeight = 20;
  2079. p2_3_5.displayWidth = 80;
  2080.  
  2081. this.tweens.timeline({
  2082.  
  2083. targets: p2_3_5.body.velocity,
  2084. loop: -1,
  2085. duration: 1000,
  2086.  
  2087. tweens: [
  2088. { x: { value: -100, ease: 'Sine.easeOut' }, y: { value: 0, ease: 'Sine.easeIn' } },
  2089. { x: { value: 0, ease: 'Sine.easeIn' }, y: { value: -100, ease: 'Sine.easeOut' } },
  2090. { x: { value: 100, ease: 'Sine.easeOut' }, y: { value: 0, ease: 'Sine.easeIn' } },
  2091. { x: { value: 0, ease: 'Sine.easeIn' }, y: { value: 100, ease: 'Sine.easeOut' } },
  2092.  
  2093. ],
  2094. onLoop: function () {
  2095. //p1_3_5.body.reset(500,115);
  2096. p2_3_5.body.reset(500 + 1180 * that_.escenarios[3].pos, 560);
  2097. }
  2098. });
  2099.  
  2100. let p2_3_6 = this.physics.add.image(600 + 1180 * this.escenarios[3].pos, 510, "elecplatform").setImmovable(true);
  2101. p2_3_6.displayHeight = 20;
  2102. p2_3_6.displayWidth = 80;
  2103.  
  2104. let p2_3_7 = this.physics.add.image(840 + 1180 * this.escenarios[3].pos, 610, "elecplatform").setImmovable(true);
  2105. p2_3_7.displayHeight = 20;
  2106. p2_3_7.displayWidth = 220;
  2107.  
  2108.  
  2109. let grupoP2_elec = this.add.group();
  2110. grupoP2_elec.add(p2_3_1);
  2111. var intermitence = setInterval(() => {
  2112. p2_3_1.alpha = p2_3_1.alpha == 1 ? 0 : 1;
  2113. p2_3_1.alpha == 1 ? grupoP2_elec.add(p2_3_1) : grupoP2_elec.remove(p2_3_1);
  2114. }, 1000);
  2115. grupoP2_elec.add(p2_3_2);
  2116. grupoP2_elec.add(p2_3_3);
  2117. grupoP2_elec.add(p2_3_4);
  2118. grupoP2_elec.add(p2_3_5);
  2119. grupoP2_elec.add(p2_3_6);
  2120. var intermitence = setInterval(() => {
  2121. p2_3_6.alpha = p2_3_6.alpha == 1 ? 0 : 1;
  2122. p2_3_6.alpha == 1 ? grupoP2_elec.add(p2_3_6) : grupoP2_elec.remove(p2_3_6);
  2123. }, 1500);
  2124. grupoP2_elec.add(p2_3_7);
  2125.  
  2126.  
  2127. //Colisión plataformas electricidad
  2128. this.physics.add.collider(this.playerD, grupoP2_elec);
  2129. }
  2130.  
  2131. crearPlataformasLaboratorio1() {
  2132. let p1_4_1 = this.physics.add.image(120 + 1180 * this.escenarios[4].pos, 275, "labplatform").setImmovable(true);
  2133. p1_4_1.displayHeight = 20;
  2134. p1_4_1.displayWidth = 80;
  2135.  
  2136. this.tweens.timeline({
  2137. targets: p1_4_1.body.velocity,
  2138. loop: -1,
  2139. tweens: [
  2140. { y: -40, duration: 3500, ease: 'Stepped' },
  2141. { y: 40, duration: 3500, ease: 'Stepped' }
  2142.  
  2143. ]
  2144. });
  2145.  
  2146. let p1_4_2 = this.physics.add.image(745 + 1180 * this.escenarios[4].pos, 315, "labplatform").setImmovable(true);
  2147. p1_4_2.displayHeight = 20;
  2148. p1_4_2.displayWidth = 80;
  2149.  
  2150. let p1_4_3 = this.physics.add.image(845 + 1180 * this.escenarios[4].pos, 275, "labplatform").setImmovable(true);
  2151. p1_4_3.displayHeight = 20;
  2152. p1_4_3.displayWidth = 90;
  2153.  
  2154. let p1_4_4 = this.physics.add.image(220 + 1180 * this.escenarios[4].pos, 305, "labplatform").setImmovable(true);
  2155. p1_4_4.displayHeight = 20;
  2156. p1_4_4.displayWidth = 80;
  2157.  
  2158. let grupoP1_Lab = this.add.group();
  2159. grupoP1_Lab.add(p1_4_1);
  2160. grupoP1_Lab.add(p1_4_2);
  2161. grupoP1_Lab.add(p1_4_3);
  2162. grupoP1_Lab.add(p1_4_4);
  2163.  
  2164. this.physics.add.collider(this.playerU, grupoP1_Lab);
  2165. }
  2166.  
  2167. crearPlataformasLaboratorio2() {
  2168. let p2_4_1 = this.physics.add.image(120 + 1180 * this.escenarios[4].pos, 635, "labplatform").setImmovable(true);
  2169. p2_4_1.displayHeight = 20;
  2170. p2_4_1.displayWidth = 80;
  2171.  
  2172. this.tweens.timeline({
  2173. targets: p2_4_1.body.velocity,
  2174. loop: -1,
  2175. tweens: [
  2176. { y: -40, duration: 3500, ease: 'Stepped' },
  2177. { y: 40, duration: 3500, ease: 'Stepped' }
  2178.  
  2179. ]
  2180. });
  2181.  
  2182. let p2_4_2 = this.physics.add.image(745 + 1180 * this.escenarios[4].pos, 675, "labplatform").setImmovable(true);
  2183. p2_4_2.displayHeight = 20;
  2184. p2_4_2.displayWidth = 80;
  2185.  
  2186. let p2_4_3 = this.physics.add.image(845 + 1180 * this.escenarios[4].pos, 635, "labplatform").setImmovable(true);
  2187. p2_4_3.displayHeight = 20;
  2188. p2_4_3.displayWidth = 90;
  2189.  
  2190. let p2_4_4 = this.physics.add.image(220 + 1180 * this.escenarios[4].pos, 665, "labplatform").setImmovable(true);
  2191. p2_4_4.displayHeight = 20;
  2192. p2_4_4.displayWidth = 80;
  2193.  
  2194. let grupoP2_Lab = this.add.group();
  2195. grupoP2_Lab.add(p2_4_1);
  2196. grupoP2_Lab.add(p2_4_2);
  2197. grupoP2_Lab.add(p2_4_3);
  2198. grupoP2_Lab.add(p2_4_4);
  2199.  
  2200.  
  2201. this.physics.add.collider(this.playerD, grupoP2_Lab);
  2202. }
  2203.  
  2204. crearPlataformasNieve1() {
  2205. let p1_5_1 = this.physics.add.image(100 + 1180 * this.escenarios[2].pos, 295, "snowplat").setImmovable(true);
  2206. p1_5_1.displayHeight = 20;
  2207. p1_5_1.displayWidth = 80;
  2208. p1_5_1.body.friction.x = 0.3;
  2209.  
  2210.  
  2211. this.tweens.timeline({
  2212. targets: p1_5_1.body.velocity,
  2213. loop: -1,
  2214. tweens: [
  2215. { x: 60, duration: 1000, ease: 'Stepped' },
  2216. { x: -60, duration: 1000, ease: 'Stepped' }
  2217.  
  2218. ]
  2219. });
  2220.  
  2221. let p1_5_2 = this.physics.add.image(300 + 1180 * this.escenarios[2].pos, 225, "snowplat").setImmovable(true);
  2222. p1_5_2.displayHeight = 20;
  2223. p1_5_2.displayWidth = 80;
  2224.  
  2225.  
  2226. let p1_5_3 = this.physics.add.image(495 + 1180 * this.escenarios[2].pos, 225, "snowplat").setImmovable(true);
  2227. p1_5_3.displayHeight = 20;
  2228. p1_5_3.displayWidth = 80;
  2229. p1_5_3.body.friction.x = 0.3;
  2230.  
  2231. this.tweens.timeline({
  2232. targets: p1_5_3.body.velocity,
  2233. loop: -1,
  2234. tweens: [
  2235. { x: -70, duration: 1500, ease: 'Stepped' },
  2236. { x: 70, duration: 1500, ease: 'Stepped' }
  2237.  
  2238. ]
  2239. });
  2240.  
  2241. let p1_5_4 = this.physics.add.image(595 + 1180 * this.escenarios[2].pos, 185, "snowplat").setImmovable(true);
  2242. p1_5_4.displayHeight = 20;
  2243. p1_5_4.displayWidth = 40;
  2244.  
  2245. let p1_5_5 = this.physics.add.image(975 + 1180 * this.escenarios[2].pos, 210, "snowplat").setImmovable(true);
  2246. p1_5_5.displayHeight = 20;
  2247. p1_5_5.displayWidth = 80;
  2248. p1_5_5.body.friction.x = 0.2;
  2249.  
  2250. this.tweens.timeline({
  2251. targets: p1_5_5.body.velocity,
  2252. loop: -1,
  2253. tweens: [
  2254. { x: -95, duration: 2500, ease: 'Stepped' },
  2255. { x: 95, duration: 2500, ease: 'Stepped' }
  2256.  
  2257. ]
  2258. });
  2259.  
  2260.  
  2261. let grupoP1_snow = this.add.group();
  2262. grupoP1_snow.add(p1_5_1);
  2263. grupoP1_snow.add(p1_5_2);
  2264. grupoP1_snow.add(p1_5_3);
  2265. grupoP1_snow.add(p1_5_4);
  2266. grupoP1_snow.add(p1_5_5);
  2267.  
  2268. this.physics.add.collider(this.playerU, grupoP1_snow);
  2269. }
  2270.  
  2271. crearPlataformasNieve2() {
  2272. let p2_5_1 = this.physics.add.image(100 + 1180 * this.escenarios[2].pos, 655, "snowplat").setImmovable(true);
  2273. p2_5_1.displayHeight = 20;
  2274. p2_5_1.displayWidth = 80;
  2275. p2_5_1.body.friction.x = 0.3;
  2276.  
  2277.  
  2278. this.tweens.timeline({
  2279. targets: p2_5_1.body.velocity,
  2280. loop: -1,
  2281. tweens: [
  2282. { x: 60, duration: 1000, ease: 'Stepped' },
  2283. { x: -60, duration: 1000, ease: 'Stepped' }
  2284.  
  2285. ]
  2286. });
  2287.  
  2288. let p2_5_2 = this.physics.add.image(300 + 1180 * this.escenarios[2].pos, 585, "snowplat").setImmovable(true);
  2289. p2_5_2.displayHeight = 20;
  2290. p2_5_2.displayWidth = 80;
  2291.  
  2292.  
  2293. let p2_5_3 = this.physics.add.image(495 + 1180 * this.escenarios[2].pos, 585, "snowplat").setImmovable(true);
  2294. p2_5_3.displayHeight = 20;
  2295. p2_5_3.displayWidth = 80;
  2296. p2_5_3.body.friction.x = 0.3;
  2297.  
  2298. this.tweens.timeline({
  2299. targets: p2_5_3.body.velocity,
  2300. loop: -1,
  2301. tweens: [
  2302. { x: -70, duration: 1500, ease: 'Stepped' },
  2303. { x: 70, duration: 1500, ease: 'Stepped' }
  2304.  
  2305. ]
  2306. });
  2307.  
  2308. let p2_5_4 = this.physics.add.image(595 + 1180 * this.escenarios[2].pos, 545, "snowplat").setImmovable(true);
  2309. p2_5_4.displayHeight = 20;
  2310. p2_5_4.displayWidth = 40;
  2311.  
  2312. let p2_5_5 = this.physics.add.image(975 + 1180 * this.escenarios[2].pos, 210 + this.game.canvas.height / 2, "snowplat").setImmovable(true);
  2313. p2_5_5.displayHeight = 20;
  2314. p2_5_5.displayWidth = 80;
  2315. p2_5_5.body.friction.x = 0.2;
  2316.  
  2317. this.tweens.timeline({
  2318. targets: p2_5_5.body.velocity,
  2319. loop: -1,
  2320. tweens: [
  2321. { x: -95, duration: 2500, ease: 'Stepped' },
  2322. { x: 95, duration: 2500, ease: 'Stepped' }
  2323.  
  2324. ]
  2325. });
  2326.  
  2327.  
  2328. let grupoP2_snow = this.add.group();
  2329. grupoP2_snow.add(p2_5_1);
  2330. grupoP2_snow.add(p2_5_2);
  2331. grupoP2_snow.add(p2_5_3);
  2332. grupoP2_snow.add(p2_5_4);
  2333. grupoP2_snow.add(p2_5_5);
  2334.  
  2335. this.physics.add.collider(this.playerD, grupoP2_snow);
  2336. }
  2337.  
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345. unlockP1() {
  2346. //console.log("unlock")
  2347.  
  2348. this.keyLockP1 = false;
  2349. }
  2350.  
  2351. unlockP2() {
  2352. //console.log("unlock")
  2353.  
  2354. this.keyLockP2 = false;
  2355. }
  2356.  
  2357.  
  2358. delayDone() {
  2359. this.playerU.body.setSize(this.playerU.width * 0.25, this.playerU.height, true)
  2360. this.playerD.body.setSize(this.playerD.width * 0.25, this.playerD.height, true)
  2361. this.playerU.setGravityY(3000);
  2362. this.playerD.setGravityY(3000);
  2363. this.empezar();
  2364. }
  2365.  
  2366.  
  2367.  
  2368. keyDelete() {
  2369. this.input.keyboard.clearCaptures();
  2370. }
  2371.  
  2372. borrarIntervalos() {
  2373.  
  2374. this.keyDelete();
  2375. var interval_id = window.setInterval("", 9999); // Get a reference to the last
  2376. // interval +1
  2377. for (var i = 1; i < interval_id; i++)
  2378. window.clearInterval(i);
  2379. //for clearing all intervals
  2380. }
  2381.  
  2382. endP1(bandera) {
  2383. console.log("bandera p1")
  2384. this.pararP1();
  2385. this.end.player1 = true;
  2386.  
  2387. if (this.end.player1 === true && this.end.player2 === true) {
  2388. this.borrarIntervalos();
  2389. this.scene.start("Victoria",{escena:null,soundManager:this.soundManager,ganador:2,name:this.playerD.name});
  2390. }
  2391. bandera.destroy();
  2392. this.BP1.destroy();
  2393. }
  2394.  
  2395. endP2(bandera) {
  2396. console.log("bandera p2")
  2397. this.pararP2();
  2398. this.end.player2 = true;
  2399. if (this.end.player1 === true && this.end.player2 === true) {
  2400. this.borrarIntervalos();
  2401. this.scene.start("Victoria",{escena:null,soundManager:this.soundManager,ganador:1,name:this.playerU.name});
  2402. }
  2403. bandera.destroy();
  2404. this.BP2.destroy();
  2405. }
  2406.  
  2407.  
  2408. }
  2409.  
  2410. /*
  2411. var particles = this.add.particles('snowFlake')
  2412. particles.depth = -10
  2413.  
  2414. var xd = particles.createEmitter({
  2415. x: this.game.canvas.width / 2,
  2416. y: -150,
  2417. lifespan: 8000,
  2418. speedX: { min: -this.game.canvas.width / 2, max: this.game.canvas.width / 2 },
  2419. speedY: { min: +100, max: +150, steps: 1 },
  2420. scale: { start: 0.1, end: 0 },
  2421. blendMode: 'ADD'
  2422. });
  2423.  
  2424. window.xd = xd;
  2425. //*/
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435. export default Scene_play;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement