Skip to content

Commit

Permalink
Added shake and punch sound effects
Browse files Browse the repository at this point in the history
  • Loading branch information
simondiep committed Aug 9, 2020
1 parent 3272e7f commit dc92174
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 13 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Note: The React web app needs to get built, whereas the node server does not.

### Not yet started

- be able to switch between minigames without having to go back to lobby (allow changing room options outside of /create)
- be able to switch between minigames and quiplash without having to go back to lobby
- play punch sound effect when stop accelerating
- play soda sound effect when shaking
- prevent excess image GET calls (base64?)
- Prevent undo text popup in iOS (issue with inputs being in PlayerGame, even though they are not rendered )
- more intense versions of shake images to indicate power (requires tracking intensity)
Expand Down
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
loop="true"
></audio>
<audio id="sound-punch" src="./punch.wav" type="audio/wav" autostart="0"></audio>
<audio id="sound-punch-hit" src="./punch-hit.wav" type="audio/wav" autostart="0"></audio>
<audio id="sound-shake" src="./shake.wav" type="audio/wav" autostart="0"></audio>
<audio id="sound-woo-yeah" src="./woo-yeah.wav" type="audio/wav" autostart="0"></audio>
</div>
</body>
Expand Down
Binary file added public/punch-hit.wav
Binary file not shown.
Binary file added public/shake.wav
Binary file not shown.
6 changes: 6 additions & 0 deletions src/pages/host/HostsGame.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
margin-top: 30px;
}

.button-bar {
display: flex;
flex-direction: column;
align-items: center;
}

.shake-player-avatar {
display: flex;
flex-direction: column;
Expand Down
32 changes: 19 additions & 13 deletions src/pages/host/HostsGame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withRouter } from "react-router";
import "./HostsGame.css";
import { getHostSocket } from "../../SocketIoConnection";
import Countdown from "react-countdown";
import { playBackgroundMusic, playPunchSound, speakText } from "./Sounds";
import { playBackgroundMusic, playPunchSound, playPunchHitSound, playShakeSound, speakText } from "./Sounds";
import holdPhoneDownImage from "../../images/hold-phone-down.png";
import holdPhoneMidImage from "../../images/hold-phone-mid.png";
import holdPhoneUpImage from "../../images/hold-phone-up.png";
Expand Down Expand Up @@ -144,6 +144,7 @@ class HostsGame extends Component {
});
socket.on("SHAKE_COUNT_UP", (playerName) => {
this.state.shakePlayers[playerName]++;
playShakeSound();
this.setState({ shakePlayers: this.state.shakePlayers });
});
socket.on("SHOW_SHAKE_RESULTS", () => {
Expand Down Expand Up @@ -184,6 +185,7 @@ class HostsGame extends Component {
} else {
this.state.punchPlayers[playerName].state = "STARTING_PUNCH";
}
playPunchHitSound();
this.setState({ punchPlayers: this.state.punchPlayers });
});
socket.on("STOPPED_PUNCH", (playerName) => {
Expand Down Expand Up @@ -420,12 +422,14 @@ class HostsGame extends Component {
<div className="all-shake-players">
{getShakeGamePlayersComponent(this.state.shakePlayers, true, this.state.gamePlayersResults)}
</div>
<button className="submit-form-button start-new-round-button" onClick={this.onStartShakeRoundClick}>
Play Again
</button>
<button className="submit-form-button start-new-game-button" onClick={this.onStartNewGameNewPlayersClick}>
Different Game
</button>
<div className="button-bar">
<button className="submit-form-button start-new-round-button" onClick={this.onStartShakeRoundClick}>
Play Again
</button>
<button className="submit-form-button start-new-game-button" onClick={this.onStartNewGameNewPlayersClick}>
Play Different Game
</button>
</div>
</div>
);
case "SHOW_PUNCH_INSTRUCTIONS":
Expand Down Expand Up @@ -479,12 +483,14 @@ class HostsGame extends Component {
<div className="all-shake-players">
{getPunchGamePlayersComponent(this.state.punchPlayers, true, this.state.gamePlayersResults)}
</div>
<button className="submit-form-button start-new-round-button" onClick={this.onStartPunchRoundClick}>
Play Again
</button>
<button className="submit-form-button start-new-game-button" onClick={this.onStartNewGameNewPlayersClick}>
Different Game
</button>
<div className="button-bar">
<button className="submit-form-button start-new-round-button" onClick={this.onStartPunchRoundClick}>
Play Again
</button>
<button className="submit-form-button start-new-game-button" onClick={this.onStartNewGameNewPlayersClick}>
Play Different Game
</button>
</div>
</div>
);
default:
Expand Down
8 changes: 8 additions & 0 deletions src/pages/host/Sounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export function playPunchSound() {
playSound("sound-punch");
}

export function playPunchHitSound() {
playSound("sound-punch-hit");
}

export function playShakeSound() {
playSound("sound-shake");
}

export function playWooYeahSound() {
playSound("sound-woo-yeah");
}
Expand Down

0 comments on commit dc92174

Please sign in to comment.