Skip to content

Commit

Permalink
He añadido música al Pokemon
Browse files Browse the repository at this point in the history
  • Loading branch information
ander authored and ander committed May 13, 2023
1 parent 8349ba7 commit daea370
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Binary file added src/Musica/BatallaPokemon.wav
Binary file not shown.
Binary file added src/Musica/Pokemon.wav
Binary file not shown.
25 changes: 24 additions & 1 deletion src/Vista_Controlador/Pantalla_De_Inicio.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import java.io.InputStream;



import Modelo.ListaJugadores;

Expand Down Expand Up @@ -47,6 +53,8 @@ public class Pantalla_De_Inicio extends JFrame implements Observer{
private Controler controler = null;
private JLabel lblError;
private JPanel Panel_Superior;
private static Clip clip1;
private static Clip clip2;

/**
* Launch the application.
Expand All @@ -57,6 +65,11 @@ public void run() {
try {
Pantalla_De_Inicio frame = new Pantalla_De_Inicio();
frame.setVisible(true);
InputStream inputStream = Pantalla_De_Inicio.class.getResourceAsStream( "/Musica/Pokemon.wav");
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(inputStream);
clip1 = AudioSystem.getClip();
clip1.open(audioInputStream);
clip1.start();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -290,6 +303,17 @@ public void update(Observable o, Object arg) {
VistaJug.setVisible(true);
}
this.setVisible(false);
clip1.close();
try {
InputStream inputStream2 = Pantalla_De_Inicio.class.getResourceAsStream( "/Musica/BatallaPokemon.wav");
AudioInputStream audioInputStream2 = AudioSystem.getAudioInputStream(inputStream2);
clip2 = AudioSystem.getClip();
clip2.open(audioInputStream2);
clip2.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
if (arg instanceof int[]) {
int[] ganador = (int[])arg;
Expand All @@ -300,7 +324,6 @@ public void update(Observable o, Object arg) {
this.setVisible(false);
//System.exit(0);


}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Vista_Controlador/Vista_Jugador.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.awt.Color;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.sound.sampled.Clip;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.SwingConstants;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class Vista_Jugador extends JFrame implements Observer{
private JLabel lab_type;*/
private int idJug;
private Controler controler = null;
private static Clip clip;


/**
Expand Down

0 comments on commit daea370

Please sign in to comment.