Skip to content

Commit

Permalink
Quick hacks to fix sound volume and the ability of the player to ente…
Browse files Browse the repository at this point in the history
…r the HUD area.
  • Loading branch information
zx96 committed Dec 6, 2014
1 parent c679ab7 commit f073fb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/me/zx96/piupiu/GameEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public GameEngine() {

//Set the explosion sound effect to reset after playing
sfxExplode.setOnEndOfMedia(() -> sfxExplode.stop());
//And keep it from being so freaking loud
sfxExplode.setVolume(0.3);

//Play the BGM and start up the Timelines
bgm.setCycleCount(MediaPlayer.INDEFINITE);
Expand Down
12 changes: 8 additions & 4 deletions src/me/zx96/piupiu/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,27 @@ public void fireProjectile() {
* PostCondition: The Player has shifted position.
*/
protected void doMovement() {
if (movingLeft ^ movingRight) {
if (movingLeft ^ movingRight) { //Prevents a potential jiggle effect
if (movingLeft) {
//Prevent player from moving past left edge of game area
if (getX() >= deltaX) setX(getX() - deltaX);
else setX(0);
}
if (movingRight) {
//Prevent player from moving past right edge of game area
if (getX() < (Dimensions.SCREEN_WIDTH - width - deltaX))
setX(getX() + deltaX);
else setX(Dimensions.SCREEN_WIDTH - width - deltaX);
}
}
if (movingUp ^ movingDown) {
if (movingUp ^ movingDown) { //Prevents a potential jiggle effect
if (movingUp) {
if (getY() >= deltaY) setY(getY() - deltaY);
else setY(0);
//Prevent player from passing into the HUD area or above
if (getY() >= (deltaY + height)) setY(getY() - deltaY);
else setY(height);
}
if (movingDown) {
//Prevent player from leaving the game area at the bottom
if (getY() < (Dimensions.SCREEN_HEIGHT - height - deltaY))
setY(getY() + deltaY);
else setY(Dimensions.SCREEN_HEIGHT - height - deltaY);
Expand Down

0 comments on commit f073fb5

Please sign in to comment.