Skip to content

Commit

Permalink
Fixed network game issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
forteri76 committed May 13, 2014
1 parent bd6c179 commit 6210661
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/org/jfedor/frozenbubble/Compressor.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@
public class Compressor {
private BmpWrap compressorHead;
private BmpWrap compressor;
double moveDown;
int steps;
private double moveDown;
private int steps;

public Compressor(BmpWrap compressorHead, BmpWrap compressor) {
this.compressorHead = compressorHead;
this.compressor = compressor;
this.moveDown = 0.;
this.steps = 0;
init();
}

public double getMoveDown() {
Expand All @@ -76,6 +75,11 @@ public int getSteps() {
return steps;
}

public void init() {
moveDown = 0.;
steps = 0;
}

public void moveDown() {
moveDown += 28.;
steps++;
Expand Down
8 changes: 8 additions & 0 deletions src/org/jfedor/frozenbubble/FrozenBubble.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ public synchronized static int getCollision() {

public synchronized static void setCollision(int newCollision) {
collision = newCollision;
BubbleSprite.setCollisionThreshold(collision);
}

public synchronized static boolean getCompressor() {
Expand Down Expand Up @@ -839,6 +840,9 @@ private void playMusic(boolean startPlaying)
allowUnpause = true;
}

/**
* Load the game options from the saved shared preferences.
*/
private void restoreGamePrefs() {
SharedPreferences mConfig = getSharedPreferences(PREFS_NAME,
Context.MODE_PRIVATE);
Expand All @@ -853,6 +857,10 @@ private void restoreGamePrefs() {
soundOn = mConfig.getBoolean("soundOn", true );
targetMode = mConfig.getInt ("targetMode", POINT_TO_SHOOT );

/*
* Some game options require additional handling to fully implement
* changes to game play.
*/
BubbleSprite.setCollisionThreshold(collision);
setTargetModeOrientation();
}
Expand Down
15 changes: 11 additions & 4 deletions src/org/jfedor/frozenbubble/FrozenGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,16 @@ private boolean checkLost() {
lost = true;
}
}


int steps = compressor.getSteps();

for (int i = 0; i < 8; i++) {
if (bubblePlay[i][12 - compressor.steps] != null) {
if (bubblePlay[i][12 - steps] != null) {
lost = true;
break;
}
}

if (lost) {
penguin.updateState(PenguinSprite.STATE_GAME_LOST);
if (highscoreManager != null)
Expand Down Expand Up @@ -459,7 +461,7 @@ public int getAttackBarBubbles() {
}

public int getCompressorSteps() {
return compressor.steps;
return compressor.getSteps();
}

public int getCurrentColor() {
Expand Down Expand Up @@ -1306,6 +1308,11 @@ public void setGrid(byte[][] newGrid) {
}
}
}
int steps = compressor.getSteps();
compressor.init();
for (int index = 0; index < steps; index++) {
lowerCompressor(false);
}
}

public void setLaunchBubbleColors(int current, int next, int newNext) {
Expand Down

0 comments on commit 6210661

Please sign in to comment.