Android Open Source - NotATop Basic Top






From Project

Back to project page NotATop.

License

The source code is released under:

GNU General Public License

If you think the Android project NotATop 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 com.gg.top;
//from   ww  w .  j a v  a2  s. c  o  m
import com.gg.util.*;

/*    ??????????????    */
public class BasicTop {
  protected Point basicPoint = new Point(0f, 0f, 0f); // ??????????xyz    
  protected float radius = 0.5f; // ????????????
  protected float coneHeight = radius; // ????
  protected float coneAngle = (float) Math.toRadians(90); // ?????????90??
  protected float cylinderHeight = radius*2; // ?????

  protected float angleCount = 0f; // ????????????????
  protected float angleSpeed = 20f; // ??????10??????15??????25???30????????40????????????
  protected float autoAngleAccelerate = -0.05f; // 0.05???15?????????0.06???12?????????????????????????????
  public final static float MAX_ANGLE_SPEED = 30f; // ???????  
  
  protected float axleAngleCount = 0f; // ??????????????  
  protected float axleAngleSpeed = 0f;// ?????????????0.1???????????0.2????????????????0.25?????????
  public final static float MAX_AXLE_ANGLE_SPEED = 15f; //

  protected float axleAngle = 0f; // ???????,20???????????,30???????
  public final float DEAD_AXLE_ANGLE = 13f; // ??????????????????????????????????????30??,15????????????
  
  protected float xShakeDistance = 0.002f; //x??????????????????????????,?????????0.005??????0.002??
  protected float yShakeDistance = 0.002f; //y??????????????????????????
  
  protected float xMoveSpeed = 0.0f; // x??????????,0.005???????
  protected float yMoveSpeed = 0.0f; // y??????????
  public final static float X_MAX_MOVE_SPEED = 0.015f; // x????????????????????0.015?????????4??
  public final static float Y_MAX_MOVE_SPEED = 0.015f; // y??????????????????,0.015???2???
  protected float xAutoMoveAccelerate = 0.00005f; // x????????????????????????0.0001?????,0.00005??????????
  protected float yAutoMoveAccelerate = 0.00005f; // y???????????????

  public final static int PREPARE = 0; // ???????
  public final static int ROTATING = 1; // ?????????
  public final static int FALLING = 2; // ?????????
  public final static int END = 3; // ??????
  protected int state = PREPARE; // ??????

  
  public BasicTop() { // ???????????

  }
  

  //????????????????????????????
  public void rotate(){
    angleCount += angleSpeed;    
    if(angleCount>360){
      angleCount -= 360;
    }
  }
  
  //????????????????????
  public void autoAngleAccelerate(){
    if(angleSpeed+autoAngleAccelerate>0){
      angleSpeed += autoAngleAccelerate;
    }else{
      angleSpeed = 0f;
    }
  }
  
  
  //??????z???????????????????????????
  public void axleRotate(){
    axleAngleCount += axleAngleSpeed;  
    if(axleAngleCount>360){
      axleAngleCount -= 360;
    }
  }
  
  //???????????????????????sin?????
  //????0??1,?????0??PI/2,??????????Sin?????,?????????,??????????(??????????)
  public void axleRotateAccelerate(){
    if(axleAngleSpeed<MAX_AXLE_ANGLE_SPEED){
      axleAngleSpeed = ((float)Math.sin(axleAngle/DEAD_AXLE_ANGLE*(Math.PI/2)))*MAX_AXLE_ANGLE_SPEED;
    }
  }
  

  
  //???????????????????????
  //????0??1,?????0??PI/2,???????PI????Sin??????,???????,????????????(??????????)???????1.2??????????????????
  public void calculateAxleAngle(){
    axleAngle = (float)(Math.sin(angleSpeed/MAX_ANGLE_SPEED*(Math.PI/2)+Math.PI)+1)*DEAD_AXLE_ANGLE*1.2f;
  }
  
  
  //??????????
  public void shake(){
    if(basicPoint.x+xShakeDistance-radius>-Constant.LOGIC_WIDTH/2 && basicPoint.x+xShakeDistance+radius<Constant.LOGIC_WIDTH){
      basicPoint.x += xShakeDistance;
    }
    if(basicPoint.y+yShakeDistance-radius>-Constant.LOGIC_HEIGHT/2 && basicPoint.y+yShakeDistance+radius<Constant.LOGIC_HEIGHT){
      basicPoint.y += yShakeDistance;
    }    
  }
  
  public void move(){
    if(basicPoint.x+xMoveSpeed-radius>-Constant.LOGIC_WIDTH/2 && basicPoint.x+xMoveSpeed+radius<Constant.LOGIC_WIDTH/2){
      basicPoint.x += xMoveSpeed;
    }
//    else{
//      xMoveSpeed = -xMoveSpeed*2/3;
//      angleSpeed = angleSpeed*4/5;
//      
//      collideFlag = true;
//    }
    
    if(basicPoint.y+yMoveSpeed-radius>-Constant.LOGIC_HEIGHT/2 && basicPoint.y+yMoveSpeed+radius<Constant.LOGIC_HEIGHT/2){
      basicPoint.y += yMoveSpeed;
    }
//    else{
//      yMoveSpeed = -yMoveSpeed*2/3;
//      angleSpeed = angleSpeed*4/5;
//      
//      collideFlag = true;
//    }
  }

  
  
  public void autoMoveAccelerate(){
    if(xMoveSpeed>0 && xMoveSpeed-xAutoMoveAccelerate>0){
      xMoveSpeed -= xAutoMoveAccelerate;
    }else if(xMoveSpeed<0 && xMoveSpeed+xAutoMoveAccelerate<0){
      xMoveSpeed += xAutoMoveAccelerate;
    }
    
    if(yMoveSpeed>0 && yMoveSpeed-yAutoMoveAccelerate>0){
      yMoveSpeed -= yAutoMoveAccelerate;
    }else if(yMoveSpeed<0 && yMoveSpeed+yAutoMoveAccelerate<0){
      yMoveSpeed += yAutoMoveAccelerate;
    }
  }
  

  
  /* ????get??set???? */
  public Point getBasicPoint() {
    return basicPoint;
  }


  public void setBasicPoint(Point basicPoint) {
    this.basicPoint = basicPoint;
  }


  public float getRadius() {
    return radius;
  }


  public void setRadius(float radius) {
    this.radius = radius;
    this.coneHeight = radius;
    this.cylinderHeight = radius*2;
  }


  public float getConeHeight() {
    return coneHeight;
  }


  public void setConeHeight(float coneHeight) {
    this.coneHeight = coneHeight;
  }


  public float getConeAngle() {
    return coneAngle;
  }


  public void setConeAngle(float coneAngle) {
    this.coneAngle = coneAngle;
  }


  public float getCylinderHeight() {
    return cylinderHeight;
  }


  public void setCylinderHeight(float cylinderHeight) {
    this.cylinderHeight = cylinderHeight;
  }



  public float getAxleAngle() {
    return axleAngle;
  }


  public void setAxleAngle(float axleAngle) {
    this.axleAngle = axleAngle;
  }


  public float getAxleAngleSpeed() {
    return axleAngleSpeed;
  }


  public void setAxleAngleSpeed(float axleAngleSpeed) {
    this.axleAngleSpeed = axleAngleSpeed;
  }


  public float getAxleAngleCount() {
    return axleAngleCount;
  }


  public void setAxleAngleCount(float axleAngleCount) {
    this.axleAngleCount = axleAngleCount;
  }


//  public float getAxleAngleDownSpeed() {
//    return axleAngleDownSpeed;
//  }
//
//
//  public void setAxleAngleDownSpeed(float axleAngleDownSpeed) {
//    this.axleAngleDownSpeed = axleAngleDownSpeed;
//  }



  public float getAngleSpeed() {
    return angleSpeed;
  }


  public void setAngleSpeed(float angleSpeed) {
    this.angleSpeed = angleSpeed;
  }


  public float getAngleCount() {
    return angleCount;
  }


  public void setAngleCount(float angleCount) {
    this.angleCount = angleCount;
  }


  public float getAutoAngleAccelerate() {
    return autoAngleAccelerate;
  }


  public void setAutoAngleAccelerate(float autoAngleAccelerate) {
    this.autoAngleAccelerate = autoAngleAccelerate;
  }


  public float getxMoveSpeed() {
    return xMoveSpeed;
  }


  public void setxMoveSpeed(float xMoveSpeed) {
    this.xMoveSpeed = xMoveSpeed;
  }


  public float getyMoveSpeed() {
    return yMoveSpeed;
  }


  public void setyMoveSpeed(float yMoveSpeed) {
    this.yMoveSpeed = yMoveSpeed;
  }





  public float getxAutoMoveAccelerate() {
    return xAutoMoveAccelerate;
  }


  public void setxAutoMoveAccelerate(float xAutoMoveAccelerate) {
    this.xAutoMoveAccelerate = xAutoMoveAccelerate;
  }


  public float getyAutoMoveAccelerate() {
    return yAutoMoveAccelerate;
  }


  public void setyAutoMoveAccelerate(float yAutoMoveAccelerate) {
    this.yAutoMoveAccelerate = yAutoMoveAccelerate;
  }


  public float getxShakeDistance() {
    return xShakeDistance;
  }


  public void setxShakeDistance(float xShakeDistance) {
    this.xShakeDistance = xShakeDistance;
  }


  public float getyShakeDistance() {
    return yShakeDistance;
  }


  public void setyShakeDistance(float yShakeDistance) {
    this.yShakeDistance = yShakeDistance;
  }


  public int getState() {
    return state;
  }


  public void setState(int state) {
    this.state = state;
  }




  public float getDEAD_AXLE_ANGLE() {
    return DEAD_AXLE_ANGLE;
  }





  public float getMAX_ANGLE_SPEED() {
    return MAX_ANGLE_SPEED;
  }




  public float getX_MAX_MOVE_SPEED() {
    return X_MAX_MOVE_SPEED;
  }




  public float getY_MAX_MOVE_SPEED() {
    return Y_MAX_MOVE_SPEED;
  }




  public float getMAX_AXLE_ANGLE_SPEED() {
    return MAX_AXLE_ANGLE_SPEED;
  }









  public int getPREPARE() {
    return PREPARE;
  }




  public int getROTATING() {
    return ROTATING;
  }




  public int getFALLING() {
    return FALLING;
  }




  public int getEND() {
    return END;
  }



}




Java Source Code List

com.gg.game.ClassicGame.java
com.gg.game.ClassicGame.java
com.gg.game.GameFrame.java
com.gg.game.GameFrame.java
com.gg.game.TimeGame.java
com.gg.game.TimeGame.java
com.gg.module.DrawBackground.java
com.gg.module.DrawBackground.java
com.gg.module.DrawScore.java
com.gg.module.DrawScore.java
com.gg.module.DrawTrack.java
com.gg.module.DrawTrack.java
com.gg.module.SelectControl.java
com.gg.module.SelectControl.java
com.gg.module.SoundControl.java
com.gg.module.SoundControl.java
com.gg.module.VoiceControl.java
com.gg.module.VoiceControl.java
com.gg.top.BasicTop.java
com.gg.top.BasicTop.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCone.java
com.gg.top.DrawCone.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawTop.java
com.gg.top.DrawTop.java
com.gg.util.Circle.java
com.gg.util.Circle.java
com.gg.util.Constant.java
com.gg.util.Constant.java
com.gg.util.DateUtil.java
com.gg.util.DateUtil.java
com.gg.util.Direction.java
com.gg.util.Direction.java
com.gg.util.Line.java
com.gg.util.Line.java
com.gg.util.Point.java
com.gg.util.Point.java
com.gg.util.TextureRect.java
com.gg.util.TextureRect.java
com.gg.util.TrackPoint.java
com.gg.util.TrackPoint.java
com.gg.util.Track.java
com.gg.util.Track.java
com.gg.util.Utils.java
com.gg.util.Utils.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.MainActivity.java
com.gg.view.MainActivity.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.WelcomeSurfaceView.java
com.gg.view.WelcomeSurfaceView.java