public void run() { laberinto1.stopCocos(); try { intro.Play(); laberinto1.drawMessage("Get Ready!"); soltarCoco = new Thread() { @Override public void run() { while (true) { try { Thread.sleep(6000); } catch (InterruptedException ex) { Logger.getLogger(ComeCocosView.class.getName()).log(Level.SEVERE, null, ex); } laberinto1.releaseCoco(); } } }; Thread.sleep(5000); laberinto1.drawMessage(""); laberinto1.reanudarCocos(); soltarCoco.start(); cocoNormal.Play(); while (continuar) { Thread.sleep(12); synchronized (this) { while (suspender) { wait(); } } if (laberinto1.pacman_muerto) { parar(); laberinto1.stopCocos(); if (t != null) t.stop(); if (soltarCoco != null) soltarCoco.stop(); cocoNormal.Stop(); waka.Stop(); die.Play(); Thread.sleep(3); panelPuntuaciones1.setVidas(--vidas); if (vidas < 0) laberinto1.drawMessage("Game Over "); else { reiniciar(); } } if (laberinto1.areComidos()) { if (laberinto1.areweakCocos()) cocoWeak.Pausa(); else cocoNormal.Pausa(); cocoComido.Play(); } else { cocoComido.Stop(); if (laberinto1.areweakCocos()) cocoWeak.Continuar(); else cocoNormal.Continuar(); } if (laberinto1.areweakCocos()) if (laberinto1.isNuevoFantasmaComido()) { int n = laberinto1.getFantasmasMuertos(); switch (n) { case 1: puntuacion += 200; break; case 2: puntuacion += 400; break; case 3: puntuacion += 800; break; case 4: puntuacion += 1600; break; } laberinto1.setNuevoFantasmaComido(false); panelPuntuaciones1.setPuntuacion(puntuacion); } switch (laberinto1.moverPacMan()) { case Laberinto.LITTLEPOINT: waka.Play(); puntuacion += 10; panelPuntuaciones1.setPuntuacion(puntuacion); break; case Laberinto.BIGPOINT: waka.Play(); puntuacion += 50; panelPuntuaciones1.setPuntuacion(puntuacion); // hebra para que vaya mas fluido el sonido t = new Thread() { @Override public void run() { try { cocoNormal.Stop(); cocoWeak.Play(); laberinto1.setweakCocos(true); Thread.sleep(6000); cocoWeak.Stop(); cocoNormal.Play(); laberinto1.setweakCocos(false); this.finalize(); } catch (Exception ex) { Logger.getLogger(ComeCocosView.class.getName()).log(Level.SEVERE, null, ex); } catch (Throwable ex) { Logger.getLogger(ComeCocosView.class.getName()).log(Level.SEVERE, null, ex); } } }; t.start(); ///////////////////////////////////////////// break; case Laberinto.GHOST: break; default: break; } laberinto1.repaint(); } // end while(continuar) } catch (InterruptedException e) { System.out.println("Hilo interrumpido: " + e); } catch (Exception ex) { Logger.getLogger(ComeCocosView.class.getName()).log(Level.SEVERE, null, ex); } }