Android Open Source - SCBIO-OneButtonLarry Larry






From Project

Back to project page SCBIO-OneButtonLarry.

License

The source code is released under:

MIT License

If you think the Android project SCBIO-OneButtonLarry 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 org.scbio.onebuttonlarry.game;
//from   w w  w  .jav a 2s  .  c  o m
import org.scbio.onebuttonlarry.R;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;

@SuppressWarnings("unused")
public abstract class Larry extends Sprite {
  
  private static final int CPERFRAME = 5;
  private static final int MAXCOUNT = 4*CPERFRAME;
  private int count = 0;

  // Resource names
  private static final int LARRY_FRAME_1 = R.drawable.larry1;
  private static final int LARRY_FRAME_2 = R.drawable.larry2;
  private static final int LARRY_FRAME_3 = R.drawable.larry3;
  private static final int LARRY_FRAME_4 = R.drawable.larry4;
  public static final int LARRY_SOUND_JUMP = R.raw.jumpsound;
  public static final int LARRY_SOUND_DIE = R.raw.deathsound;
  
  // Frame drawable
  private static Drawable larryFrame1;
  private static Drawable larryFrame2;
  private static Drawable larryFrame3;
  private static Drawable larryFrame4;
  
  public Larry(Context context, View view, float scale) {
    super(view, context.getResources().getDrawable(LARRY_FRAME_1), scale);
    
    larryFrame1 = context.getResources().getDrawable(LARRY_FRAME_1);
    larryFrame2 = context.getResources().getDrawable(LARRY_FRAME_2);
    larryFrame3 = context.getResources().getDrawable(LARRY_FRAME_3);
    larryFrame4 = context.getResources().getDrawable(LARRY_FRAME_4);
    
    setDrawable(larryFrame1);
  }
  
  public Larry(Context context, View view){  
    super(view, context.getResources().getDrawable(LARRY_FRAME_1));
    
    larryFrame1 = context.getResources().getDrawable(LARRY_FRAME_1);
    larryFrame2 = context.getResources().getDrawable(LARRY_FRAME_2);
    larryFrame3 = context.getResources().getDrawable(LARRY_FRAME_3);
    larryFrame4 = context.getResources().getDrawable(LARRY_FRAME_4);
    
    setDrawable(larryFrame1);
  }
  
  public void updateLarry(double delay)
  {
    switch (count/CPERFRAME) {
    case 0:
      setDrawable(larryFrame1);
      break;
    case 3:
    case 1:
      setDrawable(larryFrame2);
      break;
    case 2:
      setDrawable(larryFrame3);
      break;  
    default:
      setDrawable(larryFrame1);
      break;
    }
    
    count += delay;
    if(count> MAXCOUNT) count = 0;
  }
  
  protected abstract void doAction();
}




Java Source Code List

org.scbio.onebuttonlarry.AboutActivity.java
org.scbio.onebuttonlarry.GameActivity.java
org.scbio.onebuttonlarry.HighscoreActivity.java
org.scbio.onebuttonlarry.HighscoreManager.java
org.scbio.onebuttonlarry.Highscore.java
org.scbio.onebuttonlarry.MainActivity.java
org.scbio.onebuttonlarry.MusicManager.java
org.scbio.onebuttonlarry.PreferencesManager.java
org.scbio.onebuttonlarry.ResultActivity.java
org.scbio.onebuttonlarry.game.GameStage.java
org.scbio.onebuttonlarry.game.GameView.java
org.scbio.onebuttonlarry.game.Larry.java
org.scbio.onebuttonlarry.game.Sprite.java
org.scbio.onebuttonlarry.stage.GapJumpStage.java
org.scbio.onebuttonlarry.stage.PlatformsStage.java
org.scbio.onebuttonlarry.stage.RockStage.java
org.scbio.onebuttonlarry.stage.RunStopStage.java