Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pingouins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bariatti Francesco
pingouins
Commits
0d322b3c
Commit
0d322b3c
authored
8 years ago
by
Bariatti Francesco
Browse files
Options
Downloads
Patches
Plain Diff
Modified sound in GUI
parent
b4c4185c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gui/resource/pingu_theme.wav
+0
-0
0 additions, 0 deletions
gui/resource/pingu_theme.wav
gui/src/controller/Controller.java
+23
-15
23 additions, 15 deletions
gui/src/controller/Controller.java
gui/src/main/Main.java
+0
-8
0 additions, 8 deletions
gui/src/main/Main.java
with
23 additions
and
23 deletions
gui/resource/pingu_
generiqu
e.wav
→
gui/resource/pingu_
them
e.wav
+
0
−
0
View file @
0d322b3c
File moved
This diff is collapsed.
Click to expand it.
gui/src/controller/Controller.java
+
23
−
15
View file @
0d322b3c
...
...
@@ -26,6 +26,7 @@ import java.util.ResourceBundle;
public
class
Controller
implements
Initializable
{
private
static
final
String
introMusicFile
=
"./resource/pingu_theme.wav"
;
private
GameState
gameState
;
private
Process
gameProcess
;
...
...
@@ -103,6 +104,13 @@ public class Controller implements Initializable
UpdateThread
upT
=
new
UpdateThread
(
gameProcess
,
this
.
gameState
,
this
.
board
,
this
.
boardView
,
humanPlayer
,
scoreRed
,
scoreBlue
,
turnLabel
);
upT
.
setDaemon
(
true
);
upT
.
start
();
try
{
AudioPlayer
.
player
.
start
(
new
AudioStream
(
new
FileInputStream
(
introMusicFile
)));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
/**
...
...
@@ -114,6 +122,7 @@ public class Controller implements Initializable
private
int
tileNumber
;
private
final
String
clickSoundFile
=
"./resource/clic.wav"
;
public
TileClickHandler
(
int
tileNumber
)
{
...
...
@@ -130,30 +139,26 @@ public class Controller implements Initializable
}
}
@Override
public
void
handle
(
MouseEvent
event
)
private
void
playClickSound
()
{
// open the sound file as a Java input stream
String
intro
=
"./resource/clic.wav"
;
InputStream
in
=
null
;
try
{
in
=
new
FileInputStream
(
intro
);
// create an audiostream from the inputstream
AudioStream
audioStream
=
new
AudioStream
(
in
);
// play the audio clip with the audioplayer class
AudioPlayer
.
player
.
start
(
audioStream
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
try
{
AudioPlayer
.
player
.
start
(
new
AudioStream
(
new
FileInputStream
(
clickSoundFile
)));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
handle
(
MouseEvent
event
)
{
if
(!
gameState
.
getCurrent_player
().
equals
(
humanPlayer
))
return
;
if
(
selectedTile
==
tileNumber
)
//If we clicked again on the selected tile
{
playClickSound
();
//UnSelect and un-highlight previously selected and highlighted tiles
boardView
[
selectedTile
].
setSelected
(
false
);
boardView
[
selectedTile
].
update
();
...
...
@@ -163,9 +168,11 @@ public class Controller implements Initializable
}
//We clicked on a tile that wasn't previously selected
//Selecting the tile
int
penguinNb
=
gameState
.
getPenguinOnTile
(
humanPlayer
,
tileNumber
);
if
(
penguinNb
!=
-
1
)
//There is a penguin on this tile: we want to select it
{
playClickSound
();
//Unselect previously selected tiles
if
(
selectedTile
!=
-
1
)
{
...
...
@@ -217,6 +224,7 @@ public class Controller implements Initializable
}
else
if
(
boardView
[
tileNumber
].
isHighlighted
())
//There is no penguin but this is a possible move for the penguin on the selected tile
{
playClickSound
();
Move
move
=
boardView
[
tileNumber
].
getHighlightMove
();
int
moveNb
=
gameState
.
getPlayerMoveNumber
(
humanPlayer
,
gameState
.
getPenguinOnTile
(
humanPlayer
,
selectedTile
),
move
.
getDirection
(),
move
.
getSteps
());
//Before playing the move: deselect and de-highlight tiles
...
...
This diff is collapsed.
Click to expand it.
gui/src/main/Main.java
+
0
−
8
View file @
0d322b3c
...
...
@@ -32,14 +32,6 @@ public class Main extends Application
primaryStage
.
setScene
(
scene
);
primaryStage
.
setTitle
(
"Penguin game"
);
primaryStage
.
show
();
// open the sound file as a Java input stream
String
intro
=
"./resource/pingu_generique.wav"
;
InputStream
in
=
new
FileInputStream
(
intro
);
// create an audiostream from the inputstream
AudioStream
audioStream
=
new
AudioStream
(
in
);
// play the audio clip with the audioplayer class
AudioPlayer
.
player
.
start
(
audioStream
);
}
catch
(
Exception
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment