Android Open Source - CatchDROP Zen Game






From Project

Back to project page CatchDROP.

License

The source code is released under:

GNU General Public License

If you think the Android project CatchDROP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package projects.nerdybuzz.catchdrop;
//w ww .ja va  2 s  . co  m
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.TimeUtils;

public class ZenGame extends GameScreen {
  public long lastTimeInSeconds;
  public long nowTimeInSeconds;
  
  public FallingRect timePowerUp;
  private PoisonDrop poisonDrop;
  private boolean spawnedTimePowerUp = false;
  private int randomNumber1;
  private int randomNumber2;
  public static boolean spawnedPoisonDrop = false;
  public static boolean activePoisonDrop = false;
  public boolean poisonSpawnTimed;

  public ZenGame(CDGame game, int bucketX, boolean bucketTouched) {
    super(game, bucketX, bucketTouched);
    game.showMissedDrops = true;
    game.showZenScores = true;
    loseOnMissedDrop = false;
    spawnBurntToast = false;
    poisoned = false;
    game.timerTime = 60;
    nowTimeInSeconds = TimeUtils.nanosToMillis(TimeUtils.nanoTime())/1000;
    lastTimeInSeconds = nowTimeInSeconds;
        
    timePowerUp = new TimePowerUp(game);
    poisonDrop = new PoisonDrop(game, MathUtils.random(0, game.GAME_WIDTH-64), game.GAME_HEIGHT, timerFont);
    
    randomNumber1 = MathUtils.random(-5, 5);
    randomNumber2 = MathUtils.random(45, 55);
    poisonSpawnTimed = true;
    System.out.println("power-up spawning: "+randomNumber1);
    System.out.println("poison spawning: "+randomNumber2);
  }
  
  public void render(float delta) {
    super.render(delta);
    poisonDrop.render(delta);
  }
  
  public void update(float delta) {
    super.update(delta);
    poisonDrop.update(delta);
    nowTimeInSeconds = TimeUtils.nanosToMillis(TimeUtils.nanoTime())/1000;
    if(!game.paused) {
      if(lastTimeInSeconds != nowTimeInSeconds) {
        game.timerTime--;
        lastTimeInSeconds = nowTimeInSeconds;
      }
      
      if(game.timerTime == 1) {
        game.spawnDrops = false;
      }
      
      if(game.timerTime < 0) {
        game.setScreen(new EndScreen(game));
        dispose();
      }
    }
    
    if(randomNumber1 == game.timerTime && game.spawnDrops && !spawnedTimePowerUp) {
      fallingObjects.add(timePowerUp);
      spawnedTimePowerUp = true;
    }
    
    if(!spawnedPoisonDrop && !activePoisonDrop && !poisonSpawnTimed) {
      randomNumber2 = MathUtils.random(game.timerTime-10, game.timerTime);
      poisonSpawnTimed = true;
      System.out.println("poison spawning: "+randomNumber2);
    }
    
    if(randomNumber2 == game.timerTime && game.spawnDrops && !activePoisonDrop && !spawnedPoisonDrop && poisonSpawnTimed) {
      poisonDrop = new PoisonDrop(game, MathUtils.random(0, game.GAME_WIDTH-64), game.GAME_HEIGHT, timerFont);
      fallingObjects.add(poisonDrop);
      spawnedPoisonDrop = true;
      poisonSpawnTimed = false;
    }
  }
  
  public void dispose() {
    timePowerUp.dispose();
    poisonDrop.dispose();
  }

}




Java Source Code List

android.UnusedStub.java
com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.BaseGameUtils.java
com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
projects.nerdybuzz.catchdrop.BurntToastObj.java
projects.nerdybuzz.catchdrop.CDGame.java
projects.nerdybuzz.catchdrop.ClassicGame.java
projects.nerdybuzz.catchdrop.EndScreen.java
projects.nerdybuzz.catchdrop.FallingAct.java
projects.nerdybuzz.catchdrop.FallingRect.java
projects.nerdybuzz.catchdrop.GameScreen.java
projects.nerdybuzz.catchdrop.KeySequence.java
projects.nerdybuzz.catchdrop.MainMenuScreen.java
projects.nerdybuzz.catchdrop.PoisonDrop.java
projects.nerdybuzz.catchdrop.SettingsScreen.java
projects.nerdybuzz.catchdrop.TimePowerUp.java
projects.nerdybuzz.catchdrop.ZenGame.java
projects.nerdybuzz.catchdrop.android.AndroidLauncher.java
projects.nerdybuzz.catchdrop.client.HtmlLauncher.java
projects.nerdybuzz.catchdrop.desktop.AppletLauncher.java
projects.nerdybuzz.catchdrop.desktop.DesktopLauncher.java
projects.nerdybuzz.catchdrop.googleservices.DesktopGoogleServices.java
projects.nerdybuzz.catchdrop.googleservices.IGoogleServices.java