Skip to content

Commit

Permalink
Fixed accelerometer based targeting in Puzzle game mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
forteri76 committed May 18, 2014
1 parent 733c660 commit 1b1322d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jfedor.frozenbubble"
android:versionCode="28"
android:versionName="2.4">
android:versionCode="29"
android:versionName="2.5">

<supports-screens
android:smallScreens="true"
Expand Down
2 changes: 1 addition & 1 deletion src/com/efortin/frozenbubble/HomeScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public boolean onTouch(View v, MotionEvent event){
return false;
}
});
start1pGameButton.setText("1 Player");
start1pGameButton.setText("Puzzle");
start1pGameButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
start1pGameButton.setWidth((int) (start1pGameButton.getTextSize() * 9));
start1pGameButton.setTypeface(null, Typeface.BOLD);
Expand Down
34 changes: 26 additions & 8 deletions src/org/jfedor/frozenbubble/GameView.java
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ public GameThread(SurfaceHolder surfaceHolder, byte[] customLevels,
mCompressorHead, mCompressor, mLauncher,
mSoundManager, mLevelManager,
mHighScoreManager);
mPlayer1.setGameRef(mFrozenGame1);
mFrozenGame2 = null;
mNetworkManager = null;
mHighScoreManager.startLevel(mLevelManager.getLevelIndex());
Expand Down Expand Up @@ -1799,6 +1800,8 @@ public void newGame() {
mLevelManager.goToFirstLevel();
}

mPlayer1.setGameRef(null);
mFrozenGame1 = null;
mFrozenGame1 = new FrozenGame(mBackground, mBubbles, mBubblesBlind,
mFrozenBubbles, mTargetedBubbles,
mBubbleBlink, mGameWon, mGameLost,
Expand All @@ -1812,6 +1815,8 @@ public void newGame() {
mPlayer1.setGameRef(mFrozenGame1);

if (numPlayers > 1) {
mPlayer2.setGameRef(null);
mFrozenGame2 = null;
mFrozenGame2 = new FrozenGame(mBackground, mBubbles, mBubblesBlind,
mFrozenBubbles, mTargetedBubbles,
mBubbleBlink, mGameWon, mGameLost,
Expand All @@ -1837,13 +1842,16 @@ public void newGame() {
}

private void nextLevel() {
mPlayer1.setGameRef(null);
mFrozenGame1 = null;
mFrozenGame1 = new FrozenGame(mBackground, mBubbles, mBubblesBlind,
mFrozenBubbles, mTargetedBubbles,
mBubbleBlink, mGameWon, mGameLost,
mGamePaused, mHurry, mPenguins,
mCompressorHead, mCompressor, mLauncher,
mSoundManager, mLevelManager,
mHighScoreManager);
mPlayer1.setGameRef(mFrozenGame1);
if (mHighScoreManager != null) {
mHighScoreManager.startLevel(mLevelManager.getLevelIndex());
}
Expand Down Expand Up @@ -2074,6 +2082,7 @@ private void scaleFrom(BmpWrap image, Bitmap bmp) {
*/
public void setPlayerAction(PlayerAction newAction) {
VirtualInput playerRef;
FrozenGame gameRef;

if (newAction.playerID == VirtualInput.PLAYER1) {
playerRef = mPlayer1;
Expand All @@ -2085,6 +2094,13 @@ else if (newAction.playerID == VirtualInput.PLAYER2) {
return;
}

if (playerRef.mGameRef != null) {
gameRef = playerRef.mGameRef;
}
else {
return;
}

if (mGameThread != null)
mGameThread.updateStateOnEvent(null);

Expand All @@ -2098,21 +2114,21 @@ else if (newAction.playerID == VirtualInput.PLAYER2) {
(newAction.nextBubbleColor < 8) &&
(newAction.newNextBubbleColor > -1) &&
(newAction.newNextBubbleColor < 8)) {
playerRef.mGameRef.setLaunchBubbleColors(newAction.launchBubbleColor,
newAction.nextBubbleColor,
newAction.newNextBubbleColor);
gameRef.setLaunchBubbleColors(newAction.launchBubbleColor,
newAction.nextBubbleColor,
newAction.newNextBubbleColor);
}

/*
* Set the launcher aim position.
*/
playerRef.mGameRef.setPosition(newAction.aimPosition);
gameRef.setPosition(newAction.aimPosition);

/*
* Process a compressor lower request.
*/
if (newAction.compress) {
playerRef.mGameRef.lowerCompressor(true);
gameRef.lowerCompressor(true);
}

/*
Expand Down Expand Up @@ -2142,14 +2158,16 @@ else if (newAction.playerID == VirtualInput.PLAYER2) {
* Set the current value of the attack bar.
*/
if (newAction.attackBarBubbles > -1) {
playerRef.mGameRef.malusBar.setAttackBubbles(newAction.attackBarBubbles,
newAction.attackBubbles);
gameRef.malusBar.setAttackBubbles(newAction.attackBarBubbles,
newAction.attackBubbles);
}
}
}

public void setPosition(double value) {
mLocalInput.mGameRef.setPosition(value);
if (mLocalInput.mGameRef != null) {
mLocalInput.mGameRef.setPosition(value);
}
}

public void setRunning(boolean b) {
Expand Down

0 comments on commit 1b1322d

Please sign in to comment.