Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Creeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public boolean isAlive() {
if(health==0) return false;
return true;
}
public void die() {
try {
Clip dieSound = AudioSystem.getClip();
dieSound.open(AudioSystem.getAudioInputStream(new File("creeperDie.wav")));
dieSound.start();
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {}
}

// public void die() {
// try {
// Clip dieSound = AudioSystem.getClip();
// dieSound.open(AudioSystem.getAudioInputStream(new File("creeperDie.wav")));
// dieSound.start();
// } catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {}
// }

}
14 changes: 7 additions & 7 deletions Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void main(String[] args) {
JFrame display = new JFrame("My FPS Game.");
display.setSize(1000, 625);
display.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

final ViewComp picture = new ViewComp();
display.add(picture);
display.setVisible(true);
Expand Down Expand Up @@ -42,12 +42,12 @@ public void mouseClicked(MouseEvent e) {}
}
display.addMouseListener(new MoveListener());
viewUpdater.start();
try {
Clip backgroundSound = AudioSystem.getClip();
backgroundSound.open(AudioSystem.getAudioInputStream(new File("backgroundNoise.wav")));
backgroundSound.loop(Clip.LOOP_CONTINUOUSLY);
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {}

// try {
// Clip backgroundSound = AudioSystem.getClip();
// backgroundSound.open(AudioSystem.getAudioInputStream(new File("backgroundNoise.wav")));
// backgroundSound.loop(Clip.LOOP_CONTINUOUSLY);
// } catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {}
}

}
13 changes: 5 additions & 8 deletions ViewComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.io.*;

public class ViewComp extends JComponent {

private Graphics2D drawer;
Clip gunSound;
private Point mousePoint;
Expand All @@ -25,14 +25,11 @@ public ViewComp() {
enemies = new Shootable[6];
enemies[0] = new Creeper();
enemies[1] = new Creeper();
enemies[2] = new Fish();
enemies[3] = new Fish();
enemies[4] = new Bird();
enemies[5] = new Bird();
enemies[2] = new Creeper();
crossHairs = new CrossHairView();
points = 0;
}

public void firePressed() {
pressed = true;
gunSound.loop(Clip.LOOP_CONTINUOUSLY);
Expand Down Expand Up @@ -63,7 +60,7 @@ public void setViewLocation(int c, int y) {
}
}

public void paintComponent(Graphics g) {
public void paintComponent(Graphics g) {
drawer =(Graphics2D) g;
drawer.setStroke(new BasicStroke(2));
crossHairs.setLocation((int)mousePoint.getX(), (int)mousePoint.getY(), pressed);
Expand All @@ -72,7 +69,7 @@ public void paintComponent(Graphics g) {
if(enemyCounter[x]==200) {
enemies[x].draw(drawer);
if(enemies[x].contains(mousePoint)) aimed = true;
}
}
}
drawer.setColor(Color.WHITE);
drawer.setFont(new Font("Helvetica", Font.PLAIN, 20));
Expand Down
Binary file added background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zombie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zombiesmall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.