Exemple #1
0
  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();
        }
      }
    }
    */

  }
Exemple #2
0
 public int getWidth() {
   return glView.getWidth();
 }
 /**
  * Returns the width of the GLSurfaceView in pixels.
  *
  * @return width
  */
 public int getViewWidth() {
   return glSurfaceView.getWidth();
 }