Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 18, 2016
0 parents commit 9f785ce
Show file tree
Hide file tree
Showing 83 changed files with 1,147 additions and 0 deletions.
15 changes: 15 additions & 0 deletions BeginningJava8GamesDevelopment/AUDIO/down.aup
@@ -0,0 +1,15 @@
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="down_data" version="1.3.0" audacityversion="2.0.5" sel0="0.0000000000" sel1="0.0000000000" vpos="0" h="0.0000000000" zoom="1822.3889802632" rate="11025.0">
<tags/>
<wavetrack name="down" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="19456">
<waveblock start="0">
<simpleblockfile filename="e0000bf6.au" len="19456" min="-0.117706" max="0.066589" rms="0.00913"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
</project>
Binary file added BeginningJava8GamesDevelopment/AUDIO/down.wav
Binary file not shown.
Binary file added BeginningJava8GamesDevelopment/AUDIO/downmono.wav
Binary file not shown.
15 changes: 15 additions & 0 deletions BeginningJava8GamesDevelopment/AUDIO/left.aup
@@ -0,0 +1,15 @@
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="left_data" version="1.3.0" audacityversion="2.0.5" sel0="0.0000000000" sel1="0.0000000000" vpos="0" h="0.0000000000" zoom="1236.6210937500" rate="11025.0">
<tags/>
<wavetrack name="left" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="28672">
<waveblock start="0">
<simpleblockfile filename="e000046f.au" len="28672" min="-0.162659" max="0.132401" rms="0.016746"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
</project>
Binary file added BeginningJava8GamesDevelopment/AUDIO/left.wav
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions BeginningJava8GamesDevelopment/AUDIO/right.aup
@@ -0,0 +1,15 @@
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="right_data" version="1.3.0" audacityversion="2.0.5" sel0="0.0000000000" sel1="0.4411791383" vpos="0" h="0.0000000000" zoom="86.1328125000" rate="11025.0">
<tags/>
<wavetrack name="Audio Track" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="19456">
<waveblock start="0">
<simpleblockfile filename="e0000b63.au" len="19456" min="-0.102325" max="0.070282" rms="0.008035"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
</project>
Binary file not shown.
15 changes: 15 additions & 0 deletions BeginningJava8GamesDevelopment/AUDIO/s.aup
@@ -0,0 +1,15 @@
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="s_data" version="1.3.0" audacityversion="2.0.5" sel0="0.0000000000" sel1="0.0000000000" vpos="0" h="0.0000000000" zoom="1556.1973314607" rate="11025.0">
<tags/>
<wavetrack name="s" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="22784">
<waveblock start="0">
<simpleblockfile filename="e0000de8.au" len="22784" min="-0.123962" max="0.066223" rms="0.008204"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
</project>
Binary file added BeginningJava8GamesDevelopment/AUDIO/s.wav
Binary file not shown.
Binary file added BeginningJava8GamesDevelopment/AUDIO/smono.wav
Binary file not shown.
15 changes: 15 additions & 0 deletions BeginningJava8GamesDevelopment/AUDIO/up.aup
@@ -0,0 +1,15 @@
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="up_data" version="1.3.0" audacityversion="2.0.5" sel0="0.0000000000" sel1="0.0000000000" vpos="0" h="0.0000000000" zoom="3297.6562500000" rate="11025.0">
<tags/>
<wavetrack name="up" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="10752">
<waveblock start="0">
<simpleblockfile filename="e0000a30.au" len="10752" min="-0.14389" max="0.129044" rms="0.014527"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
</project>
Binary file added BeginningJava8GamesDevelopment/AUDIO/up.wav
Binary file not shown.
Binary file added BeginningJava8GamesDevelopment/AUDIO/upmono.wav
Binary file not shown.
15 changes: 15 additions & 0 deletions BeginningJava8GamesDevelopment/AUDIO/w.aup
@@ -0,0 +1,15 @@
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="w_data" version="1.3.0" audacityversion="2.0.5" sel0="0.0000000000" sel1="0.0000000000" vpos="0" h="0.0000000000" zoom="1457.9111842105" rate="11025.0">
<tags/>
<wavetrack name="w" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="24320">
<waveblock start="0">
<simpleblockfile filename="e0000600.au" len="24320" min="-0.083908" max="0.065414" rms="0.007455"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
</project>
Binary file added BeginningJava8GamesDevelopment/AUDIO/w.wav
Binary file not shown.
Binary file added BeginningJava8GamesDevelopment/AUDIO/wmono.wav
Binary file not shown.
Binary file added BeginningJava8GamesDevelopment/GIMP/enemy.xcf
Binary file not shown.
Binary file added BeginningJava8GamesDevelopment/GIMP/sprite1.xcf
Binary file not shown.
Binary file added BeginningJava8GamesDevelopment/IMAGES/bullet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/cheese.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/enemy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/prop0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/prop1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite7.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BeginningJava8GamesDevelopment/IMAGES/sprite8.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,137 @@
package invincibagel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.shape.SVGPath;
public abstract class Actor {
protected List<Image> imageStates = new ArrayList<>();
protected ImageView spriteFrame;
protected SVGPath spriteBound;
protected double iX;
protected double iY;
protected double pX;
protected double pY;
protected boolean isAlive;
protected boolean isFixed;
protected boolean isBonus;
protected boolean hasValu;
protected boolean isFlipV;
protected boolean isFlipH;
public Actor(String SVGdata, double xLocation, double yLocation, Image... spriteCels) {
spriteBound = new SVGPath();
spriteBound.setContent(SVGdata);
spriteFrame = new ImageView(spriteCels[0]);
imageStates.addAll(Arrays.asList(spriteCels));
iX = xLocation;
iY = yLocation;
pX = pY = 0;
isFixed = true;
isAlive = isBonus = hasValu = isFlipV = isFlipH = false;
}
public abstract void update();
public List<Image> getImageStates() {
return imageStates;
}

public void setImageStates(List<Image> imageStates) {
this.imageStates = imageStates;
}

public ImageView getSpriteFrame() {
return spriteFrame;
}

public void setSpriteFrame(ImageView spriteFrame) {
this.spriteFrame = spriteFrame;
}

public SVGPath getSpriteBound() {
return spriteBound;
}

public void setSpriteBound(SVGPath spriteBound) {
this.spriteBound = spriteBound;
}

public double getiX() {
return iX;
}

public void setiX(double iX) {
this.iX = iX;
}

public double getiY() {
return iY;
}

public void setiY(double iY) {
this.iY = iY;
}

public double getpX() {
return pX;
}

public void setpX(double pX) {
this.pX = pX;
}

public double getpY() {
return pY;
}

public void setpY(double pY) {
this.pY = pY;
}

public boolean isAlive() {
return isAlive;
}

public void setIsAlive(boolean isAlive) {
this.isAlive = isAlive;
}

public boolean isFixed() {
return isFixed;
}

public void setIsFixed(boolean isFixed) {
this.isFixed = isFixed;
}

public boolean isBonus() {
return isBonus;
}

public void setIsBonus(boolean isBonus) {
this.isBonus = isBonus;
}

public boolean hasValu() {
return hasValu;
}

public void setHasValu(boolean hasValu) {
this.hasValu = hasValu;
}

public boolean isFlipV() {
return isFlipV;
}

public void setIsFlipV(boolean isFlipV) {
this.isFlipV = isFlipV;
}

public boolean isFlipH() {
return isFlipH;
}

public void setIsFlipH(boolean isFlipH) {
this.isFlipH = isFlipH;
}
}
@@ -0,0 +1,155 @@
package invincibagel;
import static invincibagel.InvinciBagel.HEIGHT;
import static invincibagel.InvinciBagel.WIDTH;
import javafx.scene.image.Image;
import javafx.scene.shape.SVGPath;
import javafx.scene.shape.Shape;
public class Bagel extends Hero {
InvinciBagel invinciBagel;
protected static final double SPRITE_PIXELS_X = 81;
protected static final double SPRITE_PIXELS_Y = 81;
protected static final double rightBoundary = WIDTH - SPRITE_PIXELS_X;
protected static final double leftBoundary = 0;
protected static final double bottomBoundary = HEIGHT - SPRITE_PIXELS_Y;
protected static final double topBoundary = 0;
boolean animator = false;
int framecounter = 0;
int runningspeed = 6;
public Bagel(InvinciBagel iBagel, String SVGdata, double xLocation, double yLocation, Image... spriteCels) {
super(SVGdata, xLocation, yLocation, spriteCels);
invinciBagel = iBagel;
}
@Override
public void update(){
setXYLocation();
setBoundaries();
setImageState();
moveInvinciBagel(iX,iY);
// playAudioClip();
checkCollision();
}
private void setXYLocation() {
if(invinciBagel.isRight()) { iX+=vX; }
if(invinciBagel.isLeft()) { iX-=vX; }
if(invinciBagel.isDown()) { iY+=vY; }
if(invinciBagel.isUp()) { iY-=vY; }
}
private void setBoundaries(){
if(iX >= rightBoundary) { iX=rightBoundary; }
if(iX <= leftBoundary) { iX=leftBoundary; }
if(iY >= bottomBoundary) { iY=bottomBoundary; }
if(iY <= topBoundary) { iY=topBoundary; }
}
private void setImageState(){
if(!invinciBagel.isRight() && !invinciBagel.isLeft() && !invinciBagel.isDown() && !invinciBagel.isUp()){
spriteFrame.setImage(imageStates.get(0));
animator=false;
framecounter=0;
}
if(invinciBagel.isRight()) {
spriteFrame.setScaleX(1);
this.setIsFlipH(false);
if(!animator && (!invinciBagel.isDown() && !invinciBagel.isUp())) {
spriteFrame.setImage(imageStates.get(1));
if(framecounter >= runningspeed) {
animator=true;
framecounter=0;
} else { framecounter+=1; }
} else if(animator) {
spriteFrame.setImage(imageStates.get(2));
if(framecounter >= runningspeed) {
animator=false;
framecounter=0;
} else { framecounter+=1; }
}
}
if(invinciBagel.isLeft()) {
spriteFrame.setScaleX(-1);
this.setIsFlipH(true);
if(!animator && (!invinciBagel.isDown() && !invinciBagel.isUp())) {
spriteFrame.setImage(imageStates.get(1));
if(framecounter >= runningspeed) {
animator=true;
framecounter=0;
} else { framecounter+=1; }
} else if(animator) {
spriteFrame.setImage(imageStates.get(2));
if(framecounter >= runningspeed) {
animator=false;
framecounter=0;
} else { framecounter+=1; }
}
}
if(invinciBagel.isDown()) {
spriteFrame.setImage(imageStates.get(6));
}
if(invinciBagel.isUp()) {
spriteFrame.setImage(imageStates.get(4));
}
if(invinciBagel.iswKey()) {
spriteFrame.setImage(imageStates.get(5));
}
if(invinciBagel.issKey()) {
spriteFrame.setImage(imageStates.get(8));
}
}
private void moveInvinciBagel(double x, double y) {
spriteFrame.setTranslateX(x);
spriteFrame.setTranslateY(y);
}
private void playAudioClip(){
if(invinciBagel.isLeft()) { invinciBagel.playiSound0(); }
if(invinciBagel.isRight()) { invinciBagel.playiSound1(); }
if(invinciBagel.isUp()) { invinciBagel.playiSound2(); }
if(invinciBagel.isDown()) { invinciBagel.playiSound3(); }
if(invinciBagel.iswKey()) { invinciBagel.playiSound4(); }
if(invinciBagel.issKey()) { invinciBagel.playiSound5(); }
}
public void checkCollision(){
for (int i=0; i<invinciBagel.castDirector.getCurrentCast().size(); i++) {
Actor object = invinciBagel.castDirector.getCurrentCast().get(i);
if(collide(object)){
invinciBagel.castDirector.addToRemovedActors(object);
invinciBagel.root.getChildren().remove(object.getSpriteFrame());
invinciBagel.castDirector.resetRemovedActors();
scoringEngine(object);
}
}
}
private void scoringEngine(Actor object){
if(object instanceof Prop) {
invinciBagel.gameScore-=1;
invinciBagel.playiSound0();
} else if(object instanceof PropV) {
invinciBagel.gameScore-=2;
invinciBagel.playiSound1();
} else if(object instanceof PropH) {
invinciBagel.gameScore-=1;
invinciBagel.playiSound2();
} else if(object instanceof PropB) {
invinciBagel.gameScore-=2;
invinciBagel.playiSound3();
} else if(object instanceof Treasure) {
invinciBagel.gameScore+=5;
invinciBagel.playiSound4();
} else if(object.equals(invinciBagel.iBullet)) {
invinciBagel.gameScore-=5;
invinciBagel.playiSound5();
} else if(object.equals(invinciBagel.iCheese)) {
invinciBagel.gameScore+=5;
invinciBagel.playiSound0();
} else if(object.equals(invinciBagel.iBeagle)) {
invinciBagel.gameScore+=10;
invinciBagel.playiSound0();
}
invinciBagel.scoreText.setText(String.valueOf(invinciBagel.gameScore));
}
@Override
public boolean collide(Actor object) {
if (invinciBagel.iBagel.spriteFrame.getBoundsInParent().intersects(object.getSpriteFrame().getBoundsInParent())) {
Shape intersection = SVGPath.intersect(invinciBagel.iBagel.getSpriteBound(), object.getSpriteBound());
if (intersection.getBoundsInLocal().getWidth() != -1) { return true; }
}
return false;
}
}

0 comments on commit 9f785ce

Please sign in to comment.