Skip to content

Commit

Permalink
Merge pull request #56 from sharris40/Sprint4_SophiaMerge
Browse files Browse the repository at this point in the history
Music plays on all levels
  • Loading branch information
nsefcik committed Mar 25, 2016
2 parents 62ab279 + 31d8344 commit c116417
Show file tree
Hide file tree
Showing 13 changed files with 4,240 additions and 182 deletions.
2 changes: 1 addition & 1 deletion nbproject/UPDATED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Project RocketDog build script updated
Project build script file jfx-impl.xml in nbproject sub-directory has not been recognized
as compliant with this version of NetBeans JavaFX support module. To ensure correct
and complete functionality within this NetBeans installation the script file has been
backed up to jfx-impl_backup_5.xml and then updated to the currently supported state.
backed up to jfx-impl_backup_6.xml and then updated to the currently supported state.

FX Project build script auto-update may be triggered on project open either after
NetBeans installation update or by manual changes in jfx-impl.xml. Please note that
Expand Down
3 changes: 1 addition & 2 deletions nbproject/jfx-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3678,7 +3678,6 @@
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<jvmarg value="-Dglass.disableGrab=true"/>
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
<jvmarg line="${run.jvmargs}"/>
Expand Down Expand Up @@ -3817,7 +3816,7 @@
<target name="-debug-javaws-debuggee" depends="-init-debug-args">
<echo message="Executing ${jfx.deployment.jnlp} in debug mode using ${active.webstart.executable}"/>
<exec executable="${active.webstart.executable}">
<env key="JAVAWS_VM_ARGS" value="${debug-args-line} -Xrunjdwp:transport=${debug-transport},address=${jpda.address} -Dglass.disableGrab=true"/>
<env key="JAVAWS_VM_ARGS" value="${debug-args-line} -Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<arg value="-wait"/>
<arg file="${jfx.deployment.jnlp}"/>
</exec>
Expand Down
4,008 changes: 4,008 additions & 0 deletions nbproject/jfx-impl_backup_6.xml

Large diffs are not rendered by default.

Binary file added src/Sounds/ambienthorror.mp3
Binary file not shown.
Binary file added src/Sounds/gravedanger.mp3
Binary file not shown.
Binary file added src/Sounds/questcompleted.mp3
Binary file not shown.
Binary file added src/Sounds/rocket_explosion.mp3
Binary file not shown.
5 changes: 3 additions & 2 deletions src/edu/uco/sdd/rocketdog/model/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import java.util.Map;

public class Level extends Scene implements Observer, ILevel {

public class Level extends Scene implements Observer, ILevel {
SoundManager s;
final private RocketDog rocketDog;
final private EntityClass player;
private ArrayList<Modification> entities;
Expand Down Expand Up @@ -57,7 +59,6 @@ public Level(Group root, ImageView background, int width, int height) {
AidItems = new ArrayList<>();
ActiveAidItems = new ArrayList<>();
Hazards = new ArrayList<>();
Hazards = new ArrayList<>();

Obstructions = new ArrayList<>();
projectiles = new ArrayList<>();
Expand Down
156 changes: 79 additions & 77 deletions src/edu/uco/sdd/rocketdog/model/LevelOne.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,154 +8,157 @@
import javafx.scene.text.Text;

public class LevelOne extends Level {

Text t;
ImageView bg;
Group root;
Group houses;

SoundManager soundManager = new SoundManager();

public LevelOne(Group root, ImageView background, int width, int height) {
super(root,background,width,height);
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");

this.root = root; // Need a handle to root to add images

bg = (ImageView) root.getChildren().get(0); // Need a handle to bg to scroll

addHouses();

// Aid Items
//Shield Items
//addAidItem(new ShieldItem(new Point2D(200,200)),28,28);
//addAidItem(new ShieldItem(new Point2D(600,200)),28,28);
//addAidItem(new ShieldItem(new Point2D(400,200)),28,28);

//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(10, 100)), 56, 56);
addAidItem(new ShieldItem(new Point2D(800, 200)), 56, 56);
addAidItem(new HealthItem(new Point2D(400, 10)), 56, 56);

// Hazards
//addHazard(new HazardSpikes(new Point2D(700,300)),64,64);
//addHazard(new HazardSpikes(new Point2D(700,236)),64,64);
//addHazard(new HazardSpikes(new Point2D(700,172)),64,64);

//Obstructions
//addObstruction(new ObstructionBrickWall(new Point2D(700,300)),64,64);
//addObstruction(new ObstructionBrickWall(new Point2D(700,236)),64,64);
//addObstruction(new ObstructionBrickWall(new Point2D(700,172)),64,64);
addObstruction(new ObstructionBrickWall(new Point2D(200,624)),64,64);
addObstruction(new ObstructionBrickWall(new Point2D(200, 624)), 64, 64);
//addObstruction(new ObstructionBrickWall(new Point2D(500,624)),64,64);

//Surfaces
/*Ice ice = new Ice(400, 50);
ice.setPosition(new Point2D(150, 725));
addSurface(ice);*/

ice.setPosition(new Point2D(150, 725));
addSurface(ice);*/
// Bad Guys
EntityClass enemy = new EntityClass("Enemy");
enemy.setRelationship(getPlayer(), EntityClass.Relationship.ENEMY);
addEnemy(new Enemy.Builder("/Ugly Dog.png", 64, 64).setX(400).setY(700).setStart(350).setEnd(450).setRange(300).setEntityClass(enemy).setLevel(this).build(), 64, 64);
addEnemy(new Enemy.Builder("/Ugly Dog.png", 32, 32).setX(300).setY(650).setStart(50).setEnd(650).setRange(300).setEntityClass(enemy).setLevel(this).build(), 32, 32);
//addEnemy(new Enemy.Builder("/Ugly Dog.png", 64, 64).setX(400).setY(400).setEntityClass(enemy).setLevel(this).build(), 64, 64);
//addEnemy(new Enemy.Builder("/Ugly Dog.png", 32, 32).setX(300).setY(350).setEntityClass(enemy).setLevel(this).build(), 32, 32);
addEnemy(new DeliveryMan(500, 400),400, 400);
addEnemy(new DeliveryMan(500, 400), 400, 400);

//done
finishLevel();
}

/**
*
* Like this, zoneWidth[0] is first zone on the left
* zoneWidth[1] would be the first vertical line, zoneWidth[2]
* would be second vertical line, etc.
* +---+---+---+---+
* +---|---|---|---|
* +---|---|---|---|
* +---+---+---+---+
*
*/

*
* Like this, zoneWidth[0] is first zone on the left zoneWidth[1] would be
* the first vertical line, zoneWidth[2] would be second vertical line, etc.
* +---+---+---+---+ +---|---|---|---| +---|---|---|---| +---+---+---+---+
*
*/
private void loadMusic() {
SoundManager soundManager = new SoundManager();
soundManager.setMp_bg(soundManager.createMediaPlayer("bgmusic.mp3"));
soundManager.playMediaPlayer(soundManager.getMp_bg(), 0.1);
soundManager.setMp_am(soundManager.createMediaPlayer("forest.mp3"));
soundManager.playMediaPlayer(soundManager.getMp_am(), 0.1);
}

public void positionScreen() {
RocketDog rd = this.getRocketDog();
double width = RocketDogGame.GAME_SCREEN_WIDTH;
double height = RocketDogGame.GAME_SCREEN_HEIGHT;

double rdx = rd.getPosition().getX();
double rdy = rd.getPosition().getY();

/**
* Divide the screen into 10 zones
* Divide the screen into 10 zones
*/
int numZones = 10;
double[] zoneWidth = new double[numZones];
double[] zoneHeight = new double[numZones];
for (int i=0; i < numZones; i++) {
for (int i = 0; i < numZones; i++) {
zoneWidth[i] = i * (width / numZones);
zoneHeight[i] = i * (height / numZones);
}

if (rdx > zoneWidth[8]) {
bg.setTranslateX(bg.getTranslateX()-5);
houses.setTranslateX(houses.getTranslateX()-5);
rd.setPos(zoneWidth[8],rdy);
bg.setTranslateX(bg.getTranslateX() - 5);
houses.setTranslateX(houses.getTranslateX() - 5);
rd.setPos(zoneWidth[8], rdy);
}
if (rdx > zoneWidth[4]) {
bg.setTranslateX(bg.getTranslateX()-1);
houses.setTranslateX(houses.getTranslateX()-1);
if (rdx > zoneWidth[4]) {
bg.setTranslateX(bg.getTranslateX() - 1);
houses.setTranslateX(houses.getTranslateX() - 1);
}

//RD goes left so BG goes right
if (rdx < zoneWidth[0]) {
bg.setTranslateX(bg.getTranslateX()+1);
houses.setTranslateX(houses.getTranslateX()+1);
rd.setPos(zoneWidth[0],rdy);
bg.setTranslateX(bg.getTranslateX() + 1);
houses.setTranslateX(houses.getTranslateX() + 1);
rd.setPos(zoneWidth[0], rdy);
}

if (rdx < zoneWidth[1]) {
bg.setTranslateX(bg.getTranslateX()+1);
houses.setTranslateX(houses.getTranslateX()+1);
bg.setTranslateX(bg.getTranslateX() + 1);
houses.setTranslateX(houses.getTranslateX() + 1);
}

/* turning off vertical scrolling
if (rdy > zoneHeight[8]) {
bg.setTranslateY(bg.getTranslateY()-5);
houses.setTranslateY(houses.getTranslateY()-5);
rd.setPos(rdx,zoneHeight[8]);
}
// RD goes down so bg goes up
if (rdy > zoneHeight[7]) {
bg.setTranslateY(bg.getTranslateY()-1);
houses.setTranslateY(houses.getTranslateY()-1);
}
if (rdy > zoneHeight[8]) {
bg.setTranslateY(bg.getTranslateY()-5);
houses.setTranslateY(houses.getTranslateY()-5);
rd.setPos(rdx,zoneHeight[8]);
}
// RD goes up so bg goes down
if (rdy < zoneHeight[1]) {
bg.setTranslateY(bg.getTranslateY()+1);
houses.setTranslateY(houses.getTranslateY()+1);
}
if (rdy < zoneHeight[0]) {
bg.setTranslateY(bg.getTranslateY()+5);
houses.setTranslateY(houses.getTranslateY()+5);
rd.setPos(rdx,zoneHeight[0]);
} */
// RD goes down so bg goes up
if (rdy > zoneHeight[7]) {
bg.setTranslateY(bg.getTranslateY()-1);
houses.setTranslateY(houses.getTranslateY()-1);
}
// RD goes up so bg goes down
if (rdy < zoneHeight[1]) {
bg.setTranslateY(bg.getTranslateY()+1);
houses.setTranslateY(houses.getTranslateY()+1);
}
if (rdy < zoneHeight[0]) {
bg.setTranslateY(bg.getTranslateY()+5);
houses.setTranslateY(houses.getTranslateY()+5);
rd.setPos(rdx,zoneHeight[0]);
} */
}

/**
* We will not have a background image big enough so more background images
* We will not have a background image big enough so more background images
* will have to be added. They need to be added under a Group object so that
* they can all be moved at the same time. This would more accurately be
* be called 'addBackground' or something of that nature. They also need to be
* added before RocketDog so they are higher in the tree so Rocketdog is
* not obscured.
* they can all be moved at the same time. This would more accurately be be
* called 'addBackground' or something of that nature. They also need to be
* added before RocketDog so they are higher in the tree so Rocketdog is not
* obscured.
*/

public final void addHouses() {
// Add random houses every 300 pixels or so
houses = new Group(); // Create the Group
ImageViewLoader ldr = ImageViewLoader.getInstance();
for (int i=0; i < 10; i++) {
for (int i = 0; i < 10; i++) {
double x = Math.random() * 10 % 6 + 1; // Integer between 1 and 6
ImageView sprite = ldr.loadImage("/Resources/houses/house" + (int) x + ".png");
sprite.setTranslateX(i * 420 + 600);
Expand All @@ -164,10 +167,9 @@ public final void addHouses() {
houses.setScaleX(.7);
houses.setScaleY(.7);
houses.setTranslateY(360);
root.getChildren().add(1,houses);
root.getChildren().add(1, houses);
}



@Override
public void levelUpdate() {
super.levelUpdate();
Expand Down
8 changes: 6 additions & 2 deletions src/edu/uco/sdd/rocketdog/model/LevelTwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public class LevelTwo extends Level {
Rectangle blackSquare;
Boolean isDone;
RocketDog rocketdog;
SoundManager soundManager = new SoundManager();

public LevelTwo(Group root, int width, int height) {
public LevelTwo(Group root, int width, int height, SoundManager soundManager) {
super(root, width, height);
root.setAutoSizeChildren(false);
isDone = false;
Expand All @@ -40,6 +41,9 @@ public LevelTwo(Group root, int width, int height) {
backgroundGroup = new Group();
viewportGroup = new Group();

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

// Initialize Viewport
rocketdog = new RocketDog();
viewportGroup.getChildren().add(rocketdog.getSprite());
Expand Down Expand Up @@ -120,7 +124,7 @@ private void moveRight() {
// Do not move right of level_WIDTH
if (backgroundGroup.getTranslateX() - RocketDogGame.GAME_SCREEN_WIDTH < -LEVEL_WIDTH) {
return;
// If rocketdog would go right of the viewport, move background left
// If rocketdog would go right of the viewport, move background left
} else if (maxX + FOCAL_SPEED > VIEWPORT_MAX_X) {
backgroundGroup.setTranslateX(backgroundGroup.getTranslateX() - FOCAL_SPEED);
// Otherwise, just move the circle to the right ie move within the viewport
Expand Down
18 changes: 14 additions & 4 deletions src/edu/uco/sdd/rocketdog/model/SceneFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,38 @@ public class SceneFactory {

protected String level;
ImageViewLoader ldr;
public SoundManager soundManager;

public SceneFactory(String level) {
this.level = level;
ldr = ImageViewLoader.getInstance();
loadMusic();
}

public void setLevel(String level) {
this.level = level;
}

public Scene getLevel() {
switch (level) {
case "Splash":
return new SplashLevel(new BorderPane());
return new SplashLevel(new BorderPane(),soundManager);
case "One":
return new LevelOne(new Group(), ldr.loadImage("/Level 2.png"), GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
return new LevelOne(new Group(), ldr.loadImage("/Level 2.png"), GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT,soundManager);
case "Two":
return new LevelTwo(new Group(), LevelTwo.LEVEL_WIDTH, LevelTwo.LEVEL_HEIGHT);
return new LevelTwo(new Group(), LevelTwo.LEVEL_WIDTH, LevelTwo.LEVEL_HEIGHT,soundManager);
case "Test":
return new LevelTest(new Group(), LevelTwo.LEVEL_WIDTH, LevelTwo.LEVEL_HEIGHT);
default: // Google Style Guide: default for switch is mandatory
throw new LevelNotFound(level + " is not valid for getLevel in LevelFactory.java");
}
}

private void loadMusic() {
soundManager = new SoundManager();
soundManager.setMp_bg(soundManager.createMediaPlayer("bgmusic.mp3"));
soundManager.playMediaPlayer(soundManager.getMp_bg(), 0.1);
soundManager.setMp_am(soundManager.createMediaPlayer("forest.mp3"));
soundManager.playMediaPlayer(soundManager.getMp_am(), 0.2);
}
}
Loading

0 comments on commit c116417

Please sign in to comment.