v0.7.5d: added various safety checks

This commit is contained in:
Evan Debenham 2019-10-19 11:59:15 -04:00
parent 2c2cae01b5
commit 9c652273a5
3 changed files with 20 additions and 9 deletions

View File

@ -22,6 +22,7 @@
package com.watabou.noosa.audio; package com.watabou.noosa.audio;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.watabou.noosa.Game;
public enum Music { public enum Music {
@ -50,10 +51,15 @@ public enum Music {
return; return;
} }
try {
player = Gdx.audio.newMusic(Gdx.files.internal(assetName)); player = Gdx.audio.newMusic(Gdx.files.internal(assetName));
player.setLooping(looping); player.setLooping(looping);
player.setVolume(volume); player.setVolume(volume);
player.play(); player.play();
} catch (Exception e){
Game.reportException(e);
player = null;
}
} }

View File

@ -52,10 +52,15 @@ public class Ballistica {
public Ballistica( int from, int to, int params ){ public Ballistica( int from, int to, int params ){
sourcePos = from; sourcePos = from;
build(from, to, (params & STOP_TARGET) > 0, (params & STOP_CHARS) > 0, (params & STOP_TERRAIN) > 0); build(from, to, (params & STOP_TARGET) > 0, (params & STOP_CHARS) > 0, (params & STOP_TERRAIN) > 0);
if (collisionPos != null) if (collisionPos != null) {
dist = path.indexOf(collisionPos); dist = path.indexOf(collisionPos);
else } else if (!path.isEmpty()) {
collisionPos = path.get(dist = path.size() - 1); collisionPos = path.get(dist = path.size() - 1);
} else {
path.add(from);
collisionPos = from;
dist = 0;
}
} }
private void build( int from, int to, boolean stopTarget, boolean stopChars, boolean stopTerrain ) { private void build( int from, int to, boolean stopTarget, boolean stopChars, boolean stopTerrain ) {

View File

@ -67,7 +67,7 @@ public class WndGame extends Window {
} }
// Restart // Restart
if (!Dungeon.hero.isAlive()) { if (Dungeon.hero == null || !Dungeon.hero.isAlive()) {
RedButton btnStart; RedButton btnStart;
addButton( btnStart = new RedButton( Messages.get(this, "start") ) { addButton( btnStart = new RedButton( Messages.get(this, "start") ) {