Bläddra i källkod

gravefully sound failing, bugfixes

Kajetan Johannes Hammerle 7 år sedan
förälder
incheckning
4a14734b0f

BIN
levels/Shady_Streets.bin


+ 0 - 1
src/me/hammerle/supersnuvi/entity/EntityBuilder.java

@@ -1,6 +1,5 @@
 package me.hammerle.supersnuvi.entity;
 package me.hammerle.supersnuvi.entity;
 
 
-import java.util.Random;
 import me.hammerle.supersnuvi.entity.components.DefaultHealth;
 import me.hammerle.supersnuvi.entity.components.DefaultHealth;
 import me.hammerle.supersnuvi.entity.components.DefaultMovement;
 import me.hammerle.supersnuvi.entity.components.DefaultMovement;
 import me.hammerle.supersnuvi.entity.components.Death;
 import me.hammerle.supersnuvi.entity.components.Death;

+ 1 - 1
src/me/hammerle/supersnuvi/gamelogic/Level.java

@@ -269,7 +269,7 @@ public final class Level
                 if(tile > 0)
                 if(tile > 0)
                 {
                 {
                     data.deactivateEntity(x, y);
                     data.deactivateEntity(x, y);
-                    
+ 
                     Entity ent = EntityBuilder.fromId(tile, this, Utils.toCoord(x), Utils.toCoord(y));
                     Entity ent = EntityBuilder.fromId(tile, this, Utils.toCoord(x), Utils.toCoord(y));
                     if(ent != null)
                     if(ent != null)
                     {
                     {

+ 14 - 0
src/me/hammerle/supersnuvi/gamelogic/LevelData.java

@@ -318,6 +318,13 @@ public class LevelData
         int[][][] newLayers = new int[layers + 1][][];
         int[][][] newLayers = new int[layers + 1][][];
         System.arraycopy(tiles, 0, newLayers, 0, layers);
         System.arraycopy(tiles, 0, newLayers, 0, layers);
         newLayers[layers] = new int[width][height];
         newLayers[layers] = new int[width][height];
+        for(int x = 0; x < width; x++)
+        {
+            for(int y = 0; y < height; y++)
+            {
+                newLayers[layers][x][y] = -1;
+            }
+        }
         layers++;
         layers++;
         tiles = newLayers;
         tiles = newLayers;
     }
     }
@@ -332,6 +339,13 @@ public class LevelData
         int[][][] newLayers = new int[layers + 1][][];
         int[][][] newLayers = new int[layers + 1][][];
         System.arraycopy(tiles, 0, newLayers, 0, index);
         System.arraycopy(tiles, 0, newLayers, 0, index);
         newLayers[index] = new int[width][height];
         newLayers[index] = new int[width][height];
+        for(int x = 0; x < width; x++)
+        {
+            for(int y = 0; y < height; y++)
+            {
+                newLayers[index][x][y] = -1;
+            }
+        }
         System.arraycopy(tiles, index, newLayers, index + 1, layers - index);
         System.arraycopy(tiles, index, newLayers, index + 1, layers - index);
         layers++;
         layers++;
         tiles = newLayers;
         tiles = newLayers;

+ 23 - 6
src/me/hammerle/supersnuvi/util/SoundUtils.java

@@ -1,20 +1,37 @@
 package me.hammerle.supersnuvi.util;
 package me.hammerle.supersnuvi.util;
 
 
 import java.io.File;
 import java.io.File;
-import java.io.IOException;
+import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioInputStream;
 import javax.sound.sampled.AudioInputStream;
 import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.Clip;
 import javax.sound.sampled.Clip;
 import javax.sound.sampled.DataLine;
 import javax.sound.sampled.DataLine;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.sound.sampled.Line;
+import javax.sound.sampled.Mixer;
 import me.hammerle.supersnuvi.gamelogic.StateRenderer;
 import me.hammerle.supersnuvi.gamelogic.StateRenderer;
 
 
 public class SoundUtils 
 public class SoundUtils 
 {
 {
-    private static final AudioFormat WAV = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100.0f, 24, 1, 3, 44100.0f, false);
-    private static final DataLine.Info INFO = new DataLine.Info(Clip.class, WAV);
+    private static AudioFormat WAV;
+    private static DataLine.Info INFO;
+    
+    static
+    {
+        try
+        {
+            WAV = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100f, 24, 1, 3, 44100.0f, false);
+            INFO = new DataLine.Info(Clip.class, WAV);
+        }
+        catch(Exception ex)
+        {
+            WAV = null;
+            INFO = null;
+            ex.printStackTrace();
+        }
+    }
+    
+    
     
     
     public enum Sound
     public enum Sound
     {
     {
@@ -57,7 +74,7 @@ public class SoundUtils
                     }
                     }
                 });
                 });
             }
             }
-            catch(IOException | LineUnavailableException | UnsupportedAudioFileException ex)
+            catch(Exception ex)
             {
             {
                 System.err.println("error with 'sounds/" + path + ".wav'");
                 System.err.println("error with 'sounds/" + path + ".wav'");
                 System.err.println(ex);
                 System.err.println(ex);