예제 #1
0
파일: Hero.java 프로젝트: rrdbn4/BitBlast
  public void update(GLSurfaceView surface, GameData gamedata) {
    // position based on accelerometer
    if (((shipPosition - (change * 5)) > 0)
        && (shipPosition - (change * 5)) < (surface.getWidth() - getWidth()))
      shipPosition -= change * 5;

    // change image based on tilt
    if (change > 1 || change < -1) {
      if (change > 0) {
        srcX = 0 * width;
        // srcY = 1 * height;
      } else if (change < 0) {
        srcX = 2 * width;
        // srcY = 1 * height;
      }
    } else {
      srcX = 1 * width;
      // srcY = 0 * height;
    }

    src = new Rect(srcX, srcY, width + srcX, height + srcY);

    // Log.d("Acceleromter Data", " " + change);

    setmY((surface.getHeight() / 4) * 3);
    setmX(((int) shipPosition));

    /*
    if (burrakBoss.isMoving())
    {
      for (int i = 0; i < burrakBoss.bullets.length; i++)
      {
        if (burrakBoss.bullets[i].isMoving())
        {
          if (hit(burrakBoss.bullets[i]))
          {
            damageShip(gamedata, burrakBoss.bullets[i].getDamage());
            burrakBoss.bullets[i].resetBullet();
          }
        }
      }
    }

    for (int i = 0; i < bullets.length; i++)
    {
      if (bullets[i].isMoving())
      {
        if (hit(bullets[i]))
        {
          damageShip(gamedata, bullets[i].getDamage());
          bullets[i].resetBullet();
        }
      }
    }
    */

  }
예제 #2
0
 public int getHeight() {
   return glView.getHeight();
 }
예제 #3
0
 /**
  * Returns the height of the GLSurfaceView in pixels.
  *
  * @return height
  */
 public int getViewHeight() {
   return glSurfaceView.getHeight();
 }