Beispiel #1
0
 /** Resets the lives and the position of the paddles. */
 private void resetPaddles() {
   int mid = getWidth() / 2;
   mRed.setPosition(mid);
   mBlue.setPosition(mid);
   mGreen.setPosition(mid);
   mYellow.setPosition(mid);
   mCyan.setPosition(mid);
   mOrange.setPosition(mid);
   mRed.destination = mid;
   mBlue.destination = mid;
   mGreen.destination = mid;
   mYellow.destination = mid;
   mCyan.destination = mid;
   mOrange.destination = mid;
   mRed.setLives(STARTING_LIVES);
   mBlue.setLives(STARTING_LIVES);
 }
Beispiel #2
0
  private void initializePaddles() {
    // Order from top to bottom; Red, Green, Orange, Cyan, Yellow, Blue

    Rect redTouch = new Rect(0, 0, getWidth(), getHeight() / 8);
    Rect blueTouch = new Rect(0, 7 * getHeight() / 8, getWidth(), getHeight());
    Rect greenTouch = new Rect(0, 4 * getHeight() / 16, getWidth(), (getHeight() / 16) * 5);
    Rect orangeTouch = new Rect(0, 6 * getHeight() / 16, getWidth(), (getHeight() / 16) * 7);
    Rect yellowTouch = new Rect(0, 11 * getHeight() / 16, getWidth(), (getHeight() / 4) * 3);
    Rect cyanTouch = new Rect(0, 9 * getHeight() / 16, getWidth(), (getHeight() / 16) * 10);

    mRed = new Paddle(Color.RED, redTouch.bottom + PADDING);
    mBlue = new Paddle(Color.BLUE, blueTouch.top - PADDING - Paddle.PADDLE_THICKNESS);
    mGreen = new Paddle(Color.GREEN, greenTouch.centerY() + PADDING);
    mYellow = new Paddle(Color.YELLOW, yellowTouch.centerY() + PADDING);
    mOrange = new Paddle(Color.rgb(255, 128, 0), orangeTouch.centerY() + PADDING);
    mCyan = new Paddle(Color.rgb(0, 255, 255), cyanTouch.centerY() + PADDING);

    mRed.setTouchbox(redTouch);
    mBlue.setTouchbox(blueTouch);
    mGreen.setTouchbox(greenTouch);
    mYellow.setTouchbox(yellowTouch);
    mOrange.setTouchbox(orangeTouch);
    mCyan.setTouchbox(cyanTouch);

    mRed.setHandicap(mCpuHandicap);
    mBlue.setHandicap(mCpuHandicap);
    mGreen.setHandicap(mCpuHandicap);
    mYellow.setHandicap(mCpuHandicap);
    mOrange.setHandicap(mCpuHandicap);
    mCyan.setHandicap(mCpuHandicap);

    mRed.player = mRedPlayer;
    mBlue.player = mBluePlayer;

    mRed.setSlave(mOrange);
    mBlue.setSlave(mCyan);
    mOrange.setSlave(mYellow);
    mCyan.setSlave(mGreen);

    mRed.setLives(STARTING_LIVES + mLivesModifier);
    mBlue.setLives(STARTING_LIVES + mLivesModifier);
  }