Skip to content

Commit

Permalink
GUI UPDATE
Browse files Browse the repository at this point in the history
Sounds added
kopiert die drei *.wav-Dateien in den Ordner im target-Verzeichnis in dem der Klassenpfad der GUI-Klasse liegt.
  • Loading branch information
bjoernuhlig committed Jan 3, 2017
1 parent a90c17a commit 0881c3a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Expand Up @@ -197,6 +197,7 @@ public void actionPerformed(ActionEvent e) {
}

// destroy the current JFrame
gameview.playExitSound();
gameview.dispose();

// new game
Expand All @@ -214,6 +215,7 @@ public void actionPerformed(ActionEvent e) {
"You're a true Hobo!",
"GoodBye!",
JOptionPane.INFORMATION_MESSAGE);
gameview.playExitSound();
System.exit(0);

} else if (e.getSource() == gameview.getToogleMenu(2)) {
Expand Down Expand Up @@ -273,6 +275,7 @@ class HoboListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
try {
if (e.getSource() == gameview.getGoHobo())
gameview.playHoboGiggle();
theGame.activateHobeMode();
theGame.getLastHobeModeType();
updateGameBoard();
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/de/htw_berlin/HoboOthello/GUI/Gameview.java
Expand Up @@ -2,11 +2,14 @@

import de.htw_berlin.HoboOthello.Core.Field;
import de.htw_berlin.HoboOthello.Core.Player;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ComponentListener;
import java.io.InputStream;

/**
* Created by laura on 24.11.16.
Expand Down Expand Up @@ -405,18 +408,22 @@ public void showHint(Field field) {
*/
public void changeStone(int stone, int x, int y) {
if (stone == 0) {
playPloppSound();
fieldView[x][y].setIcon(white);

} else if (stone == 1) {
playPloppSound();
fieldView[x][y].setIcon(black);

} else if (stone == 2) {
playPloppSound();
fieldView[x][y].setIcon(grey);

} else if (stone == 3) {
Image hintImage = hint.getImage();
Image newHint = hintImage.getScaledInstance(varSmall, varSmall, java.awt.Image.SCALE_SMOOTH);
hint = new ImageIcon(newHint);
playPloppSound();
fieldView[x][y].setIcon(hint);

}
Expand Down Expand Up @@ -497,4 +504,34 @@ public void reSize(){
this.westPanel.setPreferredSize(new Dimension(newWidth,trueHeight));

}

public void playHoboGiggle() {
try {
InputStream inputStream = this.getClass().getResourceAsStream("Giggle.wav");
AudioStream audioStream = new AudioStream(inputStream);
AudioPlayer.player.start(audioStream);
} catch (Exception e){
//...to be filled
}
}

public void playExitSound() {
try {
InputStream inputStream = this.getClass().getResourceAsStream("ExitCrash.wav");
AudioStream audioStream = new AudioStream(inputStream);
AudioPlayer.player.start(audioStream);
} catch (Exception e){
//...to be filled
}
}

public void playPloppSound() {
try {
InputStream inputStream = this.getClass().getResourceAsStream("Plopp.wav");
AudioStream audioStream = new AudioStream(inputStream);
AudioPlayer.player.start(audioStream);
} catch (Exception e){
//...to be filled
}
}
}

0 comments on commit 0881c3a

Please sign in to comment.