Skip to content

Commit

Permalink
Merge branch 'develop' - Alpha 1.8.4 merge
Browse files Browse the repository at this point in the history
  • Loading branch information
redomar committed Feb 12, 2018
2 parents 26bed52 + b7498b5 commit c933e4f
Show file tree
Hide file tree
Showing 16 changed files with 275 additions and 219 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ local.properties
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover
Expand Down Expand Up @@ -182,10 +181,12 @@ JavaGame.ipr
JavaGame.iws
JavaGame.iml
out/
.idea/

###############
## Debugging ##
###############

.log.txt
/.gradle/
Package game.png
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ apply plugin: 'java'

sourceSets{
main{
java.srcDir 'src'
resources.srcDir 'res'
java.srcDirs = ['src']
resources.srcDirs = ['res']
}
test{
java.srcDir 'test'
java.srcDirs = ['test']
}
}

Expand Down
Binary file removed jar-in-jar-loader.zip
Binary file not shown.
Binary file removed jar/javagame.jar
Binary file not shown.
Binary file added res/music/small.mp3
Binary file not shown.
Binary file removed res/sfx/smallProjectile.wav
Binary file not shown.
292 changes: 174 additions & 118 deletions src/com/redomar/game/Game.java

Large diffs are not rendered by default.

54 changes: 0 additions & 54 deletions src/com/redomar/game/audio/AudioEffect.java

This file was deleted.

42 changes: 37 additions & 5 deletions src/com/redomar/game/audio/AudioHandler.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
package com.redomar.game.audio;

import com.redomar.game.script.PrintTypes;
import com.redomar.game.script.Printing;

import javax.sound.sampled.*;
import java.io.File;


public class AudioHandler {

private Clip clip;
private boolean active = false;
private Printing p = new Printing();

public AudioHandler(String path){
check(path);
}

public AudioHandler(File file){
check(file.toString());
}

private void check(String path){
try {
if(path != ""){
initiate(path);
} else {
throw new NullPointerException();
}
} catch (NullPointerException e){
p.print("Destination Cannot be empty", PrintTypes.ERROR);
throw e;
}
}

private void initiate(String path){
try{
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(getClass().getResourceAsStream(path));
AudioFormat baseformat = audioInputStream.getFormat();
Expand All @@ -26,15 +52,21 @@ public AudioHandler(String path){
clip.open(decodedAudioInputStream);
} catch (Exception e){
System.err.println(e.getStackTrace());
p.print("Audio Failed to initiate", PrintTypes.ERROR);
}
}

public void play(){
if(clip == null) return;
stop();
clip.setFramePosition(0);
clip.start();
active = true;
try{
if(clip == null) return;
stop();
clip.setFramePosition(0);
clip.start();
active = true;
} catch (Exception e) {
p.print("Audio Failed to play", PrintTypes.ERROR);
throw e;
}
}

public void setVolume(float velocity){
Expand Down
1 change: 0 additions & 1 deletion src/com/redomar/game/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.redomar.game.Game;
import com.redomar.game.InputHandler;
import com.redomar.game.audio.AudioEffect;
import com.redomar.game.entities.efx.Swim;
import com.redomar.game.entities.projectiles.Medium;
import com.redomar.game.entities.projectiles.Projectile;
Expand Down
12 changes: 7 additions & 5 deletions src/com/redomar/game/entities/projectiles/Small.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.redomar.game.entities.projectiles;

import com.redomar.game.audio.AudioEffect;
import com.redomar.game.audio.AudioHandler;
import com.redomar.game.gfx.Colours;
import com.redomar.game.gfx.Screen;
import com.redomar.game.level.LevelHandler;

import java.io.File;

public class Small extends Projectile{

public static final int FIRE_RATE = 10;
private static final File smallShot = new File("/music/small.mp3");
private static AudioHandler smallSound;

public Small(LevelHandler level, int x, int y, double dir) {
super(level, x, y, dir);
Expand All @@ -18,10 +22,8 @@ public Small(LevelHandler level, int x, int y, double dir) {
nx = speed * Math.cos(angle);
ny = speed * Math.sin(angle);

//smallSound.setVolume(-15);

AudioEffect smallSound;
smallSound = new AudioEffect("/sfx/smallProjectile.wav");
smallSound = new AudioHandler(smallShot);
smallSound.setVolume(-15);
smallSound.play();
}

Expand Down
12 changes: 4 additions & 8 deletions src/com/redomar/game/menu/Menu.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.redomar.game.menu;

import com.redomar.game.Game;
import com.redomar.game.audio.AudioEffect;
import com.redomar.game.audio.AudioHandler;
import com.redomar.game.entities.Player;
import com.redomar.game.lib.Font;
import com.redomar.game.lib.Mouse;
import com.thehowtotutorial.splashscreen.JSplash;
Expand All @@ -24,7 +22,7 @@ public class Menu implements Runnable {
private static final String NAME = "Menu";

private static boolean running = false;
private static boolean selectedStart = false;
private static boolean selectedStart = true;
private static boolean selectedExit = false;
private static boolean gameOver = false;

Expand All @@ -49,13 +47,11 @@ public static void play() {
splash.toFront();
splash.requestFocus();
splash.splashOn();
splash.setProgress(10, "Initializing SFX");

splash.setProgress(30, "Loading Music");
splash.setProgress(20, "Loading Music");
Game.setBackgroundMusic(new AudioHandler("/music/Towards The End.mp3"));
splash.setProgress(40, "Setting Volume");
splash.setProgress(50, "Setting Volume");
Game.getBackgroundMusic().setVolume(-20);
splash.setProgress(50, "Acquiring data: Multiplayer");
splash.setProgress(60, "Acquiring data: Multiplayer");
Thread.sleep(125);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
String multiMsg = "Sorry but multiplayer has been disabled on this version.\nIf you would like multiplayer checkout Alpha 1.6";
Expand Down
12 changes: 9 additions & 3 deletions src/com/redomar/game/script/PopUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
public class PopUp{

private JFrame frame;
public boolean active;

public PopUp(){
frame = Game.getFrame();
active = true;
}

public int Warn(String msg){
Object[] options = {"Continue"};
return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[0]);
if (active) {
frame = Game.getFrame();
return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[0]);
}
else
return 1;
}
}
21 changes: 0 additions & 21 deletions test/com/redomar/game/audio/AudioEffectTest.java

This file was deleted.

17 changes: 17 additions & 0 deletions test/com/redomar/game/audio/AudioHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ public void bgMusicExists() throws Exception {
assertTrue(sfx.exists());
}

@Test(expected = NullPointerException.class)
public void expectReturnExceptionFileEmptyDir(){
File empty = new File("");
AudioHandler audio = new AudioHandler(empty);
}

@Test(expected = NullPointerException.class)
public void expectReturnExceptionFileEmptyPath(){
AudioHandler audio = new AudioHandler("");
}

@Test
public void tryInitiatingAndPlayingNonExistingFile(){
AudioHandler audio = new AudioHandler("//");
audio.play();
}

}
22 changes: 22 additions & 0 deletions test/com/redomar/game/script/PopUpTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.redomar.game.script;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class PopUpTest {
private PopUp popUp;

@Before
public void setUp() throws Exception {
popUp = new PopUp();
popUp.active = false;
}

@Test
public void warnIntEfflux() throws Exception {
assertEquals(1,popUp.Warn("TEST"));
}

}

0 comments on commit c933e4f

Please sign in to comment.