Skip to content

Commit

Permalink
Added whip sound effect and bubble swap feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
forteri76 committed Apr 3, 2013
1 parent bb51cbb commit 7aca216
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 54 deletions.
Binary file added res/raw/whip.ogg
Binary file not shown.
6 changes: 2 additions & 4 deletions src/com/efortin/frozenbubble/HighscoreManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
public class HighscoreManager {

private int currentLevel = 0;
private int lastLevel = 0;
private long startTime = 0;
private long pausedTime = 0;
private long lastScoreId = -1;
Expand Down Expand Up @@ -122,7 +121,6 @@ public void lostLevel() {

public void startLevel(int level) {
startTime = System.currentTimeMillis();
lastLevel = currentLevel;
currentLevel = level;
pausedTime = 0;
// Log.i("FrozenBubble-highscore", "startLevel(" + level + ")");
Expand Down Expand Up @@ -160,8 +158,8 @@ public List<HighscoreDO> getHighscore(int level, int limit) {
return db.selectByLevel(level, limit);
}

public int getLastLevel() {
return lastLevel;
public int getLevel() {
return currentLevel;
}

public long getLastScoreId() {
Expand Down
3 changes: 2 additions & 1 deletion src/org/jfedor/frozenbubble/FrozenBubble.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public class FrozenBubble extends Activity
public final static int SOUND_HURRY = 6;
public final static int SOUND_NEWROOT = 7;
public final static int SOUND_NOH = 8;
public final static int NUM_SOUNDS = 9;
public final static int SOUND_WHIP = 9;
public final static int NUM_SOUNDS = 10;

public final static int GAME_NORMAL = 0;
public final static int GAME_COLORBLIND = 1;
Expand Down
40 changes: 37 additions & 3 deletions src/org/jfedor/frozenbubble/FrozenGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public class FrozenGame extends GameScreen {
SoundManager soundManager;

boolean readyToFire;
boolean swapPressed;
boolean endOfGame;
boolean frozenify;
int frozenifyX, frozenifyY;
Expand Down Expand Up @@ -180,6 +181,7 @@ public FrozenGame(BmpWrap background_arg,
play_result = GAME_PLAYING;
game_result = GAME_LOST;
launchBubblePosition = 20;
swapPressed = false;

penguin = new PenguinSprite(penguins_arg, random);
this.addSprite(penguin);
Expand Down Expand Up @@ -215,7 +217,7 @@ public FrozenGame(BmpWrap background_arg,
}

currentColor = bubbleManager.nextBubbleIndex(random);
nextColor = bubbleManager.nextBubbleIndex(random);
nextColor = bubbleManager.nextBubbleIndex(random);

if (FrozenBubble.getMode() == FrozenBubble.GAME_NORMAL) {
nextBubble = new ImageSprite(new Rect(302, 440, 302 + 32, 440 + 32),
Expand Down Expand Up @@ -562,12 +564,14 @@ private void blinkLine(int number)
}
}

public int play(boolean key_left, boolean key_right, boolean key_fire,
public int play(boolean key_left, boolean key_right,
boolean key_fire, boolean key_swap,
double trackball_dx,
boolean touch_fire, double touch_x, double touch_y,
boolean ats_touch_fire, double ats_touch_dx)
{
boolean ats = FrozenBubble.getAimThenShoot();

if ((ats && ats_touch_fire) || (!ats && touch_fire)) {
key_fire = true;
}
Expand All @@ -581,11 +585,22 @@ public int play(boolean key_left, boolean key_right, boolean key_fire,
} else {
move[HORIZONTAL_MOVE] = 0;
}

if (key_fire) {
move[FIRE] = KEY_UP;
} else {
move[FIRE] = 0;
}

if (key_swap) {
if (!swapPressed) {
swapNextLaunchBubble();
swapPressed = true;
}
} else {
swapPressed = false;
}

if (!ats && touch_fire && movingBubble == null) {
double xx = touch_x - 318;
double yy = 406 - touch_y;
Expand Down Expand Up @@ -657,7 +672,7 @@ public int play(boolean key_left, boolean key_right, boolean key_fire,
this.addSprite(movingBubble);

currentColor = nextColor;
nextColor = bubbleManager.nextBubbleIndex(random);
nextColor = bubbleManager.nextBubbleIndex(random);

if (FrozenBubble.getMode() == FrozenBubble.GAME_NORMAL) {
nextBubble.changeImage(bubbles[nextColor]);
Expand Down Expand Up @@ -848,4 +863,23 @@ public void setPosition(double value) {
launchBubble.changeDirection((int)launchBubblePosition);
penguin.updateState(PenguinSprite.STATE_VOID);
}

public void swapNextLaunchBubble()
{
if (currentColor != nextColor)
{
int tempColor = currentColor;
currentColor = nextColor;
nextColor = tempColor;

launchBubble.changeColor(currentColor);

if (FrozenBubble.getMode() == FrozenBubble.GAME_NORMAL)
nextBubble.changeImage(bubbles[nextColor]);
else
nextBubble.changeImage(bubblesBlind[nextColor]);

soundManager.playSound(FrozenBubble.SOUND_WHIP);
}
}
}
3 changes: 2 additions & 1 deletion src/org/jfedor/frozenbubble/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public void paint(Canvas c, double scale, int dx, int dy) {
}

public abstract int play(boolean key_left, boolean key_right,
boolean key_fire, double trackball_dx,
boolean key_fire, boolean key_swap,
double trackball_dx,
boolean touch_fire,
double touch_x, double touch_y,
boolean ats_touch_fire, double ats_touch_dx);
Expand Down
Loading

0 comments on commit 7aca216

Please sign in to comment.