Skip to content

Commit

Permalink
Changed audio volume for demo purposes.
Browse files Browse the repository at this point in the history
Added updateKeys method in Level and an overrided updateKeys
in LevelTwo to get key presses to work for the demo (hotfix needs proper fixing).
  • Loading branch information
NoahSefcik committed Mar 26, 2016
1 parent c116417 commit f06f6d1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
6 changes: 3 additions & 3 deletions scenicView.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ScenicView properties
#Thu Mar 24 22:40:24 CDT 2016
#Fri Mar 25 20:07:56 CDT 2016
showDefaultProperties=true
showSearchBar=true
autoRefreshStyleSheets=false
showSearchBar=true
showBounds=true
ignoreMouseTransparentNodes=true
splitPaneDividerPosition=0.48802083333333335
splitPaneDividerPosition=0.4953125
collapseControls=true
showFilteredNodesInTree=true
showCSSProperties=false
Expand Down
2 changes: 2 additions & 0 deletions src/edu/uco/sdd/rocketdog/controller/DefaultKeyMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.uco.sdd.rocketdog.model.Animations.SpitzDeadAnimateStrategy;
import edu.uco.sdd.rocketdog.model.Animations.SpitzIdleAnimateStrategy;
import edu.uco.sdd.rocketdog.model.HealthItem;
import edu.uco.sdd.rocketdog.model.Level;
import javafx.geometry.Point2D;
import javafx.scene.input.KeyEvent;
Expand Down Expand Up @@ -86,6 +87,7 @@ public void handleKeyPressed(Level currentLevel, KeyEvent keyEvent, double speed
break;
case P:
currentLevel.setDone(true);
break;
case O:
//game.displayOptionsScreen();
break;
Expand Down
17 changes: 11 additions & 6 deletions src/edu/uco/sdd/rocketdog/model/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


public class Level extends Scene implements Observer, ILevel {
SoundManager s;
public SoundManager s;
final private RocketDog rocketDog;
final private EntityClass player;
private ArrayList<Modification> entities;
Expand Down Expand Up @@ -404,16 +404,20 @@ public int getLargeLaserCharge(){
return largeLaserCharge;
}

@Override
public void levelUpdate() {
//Keyboard Handling
public void updateKeys() {
this.setOnKeyPressed((KeyEvent event) -> {
keyMapping.getKeyMapping().handleKeyPressed(this, event, 3.0d + rocketDog.getAgilityAttribute());
});

this.setOnKeyReleased((KeyEvent event) -> {
keyMapping.getKeyMapping().handleKeyReleased(this, event, 0.0d);
});
}

@Override
public void levelUpdate() {
//Keyboard Handling
updateKeys();

//Update RocketDog
rocketDog.update();
Expand Down Expand Up @@ -540,7 +544,8 @@ public void levelUpdate() {
rocketDog.setPowerAttribute(25);
rocketDog.setDefenseAttribute(50);
rocketDog.setAgilityAttribute(5);
//update(rocketDog.getCurrentHealth());
rocketDog.setLuckAttribute(2);
update(rocketDog.getCurrentHealth());
removeAidItem(aidItem);
} else if (aidItem.isColliding() && aidItem.getClass() == edu.uco.sdd.rocketdog.model.BoostItem.class) {
removeAidItem(aidItem);
Expand All @@ -561,7 +566,7 @@ public void levelUpdate() {
if (!activeAidItem.isActive()) {
rocketDog.setPowerAttribute(0);
rocketDog.setAgilityAttribute(1);
rocketDog.setAgilityAttribute(1);
rocketDog.setLuckAttribute(1);
rocketDog.setDefenseAttribute(1);
update(rocketDog.getCurrentHealth());
removeActiveAidItem(activeAidItem);
Expand Down
8 changes: 5 additions & 3 deletions src/edu/uco/sdd/rocketdog/model/LevelOne.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ public class LevelOne extends Level {
ImageView bg;
Group root;
Group houses;
SoundManager soundManager = new SoundManager();
public SoundManager soundManager = new SoundManager();

public LevelOne(Group root, ImageView background, int width, int height, SoundManager soundManager) {
super(root, background, width, height);
t = new Text();
this.soundManager = soundManager;
soundManager.resetMediaPlayer(this.soundManager.getMp_bg(), "ambienthorror.mp3");

soundManager.mp_bg.setVolume(0.05);
soundManager.mp_bg.setCycleCount(100);
soundManager.mp_am.setMute(true);
this.root = root; // Need a handle to root to add images

bg = (ImageView) root.getChildren().get(0); // Need a handle to bg to scroll
Expand All @@ -35,7 +37,7 @@ public LevelOne(Group root, ImageView background, int width, int height, SoundMa
//health items
addAidItem(new HealthItem(new Point2D(10, 100)), 56, 56);
addAidItem(new ShieldItem(new Point2D(800, 200)), 56, 56);
addAidItem(new HealthItem(new Point2D(400, 10)), 56, 56);
//addAidItem(new HealthItem(new Point2D(400, 10)), 56, 56);

// Hazards
//addHazard(new HazardSpikes(new Point2D(700,300)),64,64);
Expand Down
14 changes: 13 additions & 1 deletion src/edu/uco/sdd/rocketdog/model/LevelTwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,23 @@ public LevelTwo(Group root, int width, int height, SoundManager soundManager) {
super(root, width, height);
root.setAutoSizeChildren(false);
isDone = false;
super.getKeyMapping().setKeyMapping(null);

// Initialize Groups
backgroundGroup = new Group();
viewportGroup = new Group();

soundManager.resetMediaPlayer(soundManager.getMp_bg(), "intense.mp3");

soundManager.mp_bg.setVolume(0.04);
soundManager.mp_bg.setCycleCount(100);
soundManager.mp_am.setMute(true);

this.soundManager = soundManager;
soundManager.resetMediaPlayer(this.soundManager.getMp_bg(), "intense.mp3");

// Initialize Viewport
rocketdog = new RocketDog();
super.update(rocketdog.getCurrentHealth());
viewportGroup.getChildren().add(rocketdog.getSprite());

// Initialize Background objects
Expand All @@ -56,7 +63,11 @@ public LevelTwo(Group root, int width, int height, SoundManager soundManager) {
// Add Viewport + Background to root
root.getChildren().add(viewportGroup);
root.getChildren().add(backgroundGroup);
}

public void updateKeys() {
//This method overrides the updateKeys method in the parent
//when it is called in super.levelUpdate();
this.setOnKeyPressed((KeyEvent event) -> {
switch (event.getCode()) {
case LEFT:
Expand Down Expand Up @@ -85,6 +96,7 @@ public boolean isDone() {

@Override
public void levelUpdate() {
super.levelUpdate();
rocketdog.update();

}
Expand Down
6 changes: 4 additions & 2 deletions src/edu/uco/sdd/rocketdog/model/SplashLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public SplashLevel(BorderPane root, SoundManager soundManager) {
super(root,1000,924);
isDone = false;
this.root = root;
soundManager.mp_bg.setVolume(0.02);
soundManager.mp_am.setMute(true);
this.soundManager= soundManager;
HBox hboxTop= addHBox();
HBox hboxBottom=addHBox();
Expand Down Expand Up @@ -189,7 +191,7 @@ public void createMusicControls(){
root.getChildren().add(vCheckBox);
musicLabel = new Label("Music");
ambianceVolumeLabel= new Label("Ambient");
musicSlider = new Slider(0.0, 1.0, 1.0);
musicSlider = new Slider(0.0, 0.4, 0.4);
ambientSlider = new Slider(0.0, 1.0, 1.0);
}
public GridPane createOptionsGridPane(){
Expand All @@ -201,7 +203,7 @@ public GridPane createOptionsGridPane(){

createOptionsButtons();
createMusicControls();
musicSlider.setValue(soundManager.mp_bg.getVolume());
musicSlider.setValue(0.2);
ambientSlider.setValue(soundManager.mp_am.getVolume());
//column then rown
GridPane.setConstraints(optionsDefaultButton, 0, 3);
Expand Down

0 comments on commit f06f6d1

Please sign in to comment.