public void mousePressed() {
    if (game.screen == 1) { // see above
      velocity =
          PVector.fromAngle(
              radians(
                  (float)
                      angledegrees)); // uses PVector to make a vector from the angle of the shooter
      if (canfire == true) { // checks if user is able to fire (if ball is active)
        game.shooterlist[0] = game.shooterlist[1]; // sets active ball to the next ball
        game.shooterlist[0].setVelocity(
            velocity.x, velocity.y); // adjusts velocity for ball depending on type
        game.shooterlist[1] =
            new Ball(
                game
                    .createNewBall()); // creates new ball with random type as generated by the
                                       // createNewBall function
        canfire = false; // disables firing while ball is active
      }
    }

    if (game.screen == 0) { // see above
      if (button.pressed()) { // checks if button is pressed
        game.gotoGame(); // loads game
      }
    }

    if (game.screen == 2) {
      if (button.pressed()) {
        game.reset(); // resets game
      }
    }
  }
Пример #2
0
 public void resetAllData() {
   didPressStart = false;
   didPressInfo = false;
   b1.col = c.white;
   b2.col = c.white;
   b3.col = c.white;
 }
Пример #3
0
 public void display() {
   textSize(16);
   text("Type The Words Below:", 250, 190);
   tester.display();
   fill(c.white);
   textSize(16);
   text("Your input:", 250, 290);
   user.display();
 }
Пример #4
0
  public void CONFIGoff() {

    myPort.write("j"); // exit config command
    buttonWRITE.setColorBackground(gray_);
    buttonREAD.setColorBackground(gray_);
    buttonCONFon.setColorBackground(gray_);
    buttonCONFoff.setColorBackground(green_);
    writeEnable = false;
    readEnable = false;
  }
Пример #5
0
  public void CONFIGon() {

    myPort.write("i"); // enter config command
    buttonWRITE.setColorBackground(green_);
    buttonREAD.setColorBackground(green_);
    buttonCONFon.setColorBackground(green_);
    buttonCONFoff.setColorBackground(gray_);
    writeEnable = true;
    readEnable = true;
  }
Пример #6
0
  public void P2() {

    buttonP0.setColorBackground(gray_);
    buttonP1.setColorBackground(gray_);
    buttonP2.setColorBackground(green_);
    // Open the port you are using at the rate you want:
    if (portopen == true) {
      myPort.stop();
    }
    myPort = new Serial(this, Serial.list()[2], 9600);
    portopen = true;
  }
Пример #7
0
    public void mPressed(float mx, float my) {

      if (nextButton.isClicked(mx, my) && isWordCorrect) {
        checkButton.enabled = true;

        wordIndex = wordIndex + 1;
        if (wordIndex >= 10) {
          if (!level1.isComplete()) {
            level1.complete = true;
          } else if (!level2.isComplete()) {
            level2.complete = true;
          } else if (!level3.isComplete()) {
            level3.complete = true;
          }
          wordIndex = 0;
        }
        isWordCorrect = false;
        tfs.setUserWord("");
      } else if (checkButton.isClicked(mx, my) && checkButton.enabled) {
        if (tfs.getTesterWord().equals(tfs.getUserWord())) {
          print("Correct\n");
          checkButton.enabled = false;
          isWordCorrect = true;
          score.incrementScore();
        } else {
          print("Wrong\n");
          if (score.getScore() > 0) {
            score.decrementScore();
          }
        }
      }

      if (startOver.isClicked(mx, my) && level2.isComplete()) {
        quitPressed = true;
      }

      if (quit.isClicked(mx, my)) {
        quit.col = c.gray;
        quitPressed = true;
      }

      if (!level1.isComplete()) {
        if (!level1.didStart()) {
          level1.mPressed(mx, my);
          if (level1.didStart()) {
            checkButton.enabled = true;
          }
        }
      } else if (!level2.isComplete()) {
        if (!level2.didStart()) {
          level2.mPressed(mx, my);
        }
      } else if (!level3.isComplete()) {
        if (!level3.didStart()) {
          level3.mPressed(mx, my);
        }
      }

      tfs.mPressed(mx, my);
    }
Пример #8
0
    public void resetAllData() {
      quitPressed = false;
      quit.col = c.white;
      nextButton.col = c.white;
      checkButton.col = c.white;
      isWordCorrect = false;

      wordIndex = 0;

      level1.resetAllData();
      level2.resetAllData();
      level3.resetAllData();
      score.resetAllData();
      tfs.resetAllData();
    }
Пример #9
0
    public void display() {
      quit.display();

      if (!level1.isComplete()) {
        fill(c.white);
        textSize(32);
        text(level1.header, 290, 40);
        if (!level1.didStart()) {
          level1.displayStartButton();
        } else if (level1.didStart()) {
          tfs.setTesterWord(level1.wordAtIndex(wordIndex));
          tfs.display();
          checkButton.display();

          if (isWordCorrect) {
            nextButton.display();
          }
        }
      } else if (!level2.isComplete()) {
        fill(c.white);
        textSize(32);
        text(level2.header, 290, 40);
        if (!level2.didStart()) {
          level2.displayStartButton();
        } else if (level2.didStart()) {
          tfs.setTesterWord(level2.wordAtIndex(wordIndex));
          tfs.display();
          checkButton.display();

          if (isWordCorrect) {
            nextButton.display();
          }
        }
      } else if (!level3.isComplete()) {
        fill(c.white);
        textSize(32);
        text(level3.header, 290, 40);
        if (!level3.didStart()) {
          level3.displayStartButton();
        } else if (level3.didStart()) {
          tfs.setTesterWord(level3.wordAtIndex(wordIndex));
          tfs.display();
          checkButton.display();

          if (isWordCorrect) {
            nextButton.display();
          }
        }
      } else {
        fill(c.white);
        textSize(32);
        text("Congratulations For Finishing The Game!", 30, 200);
        startOver.display();
      }

      score.display();
    }
Пример #10
0
  public void READ() {
    if (readEnable == false) return;

    myPort.write("g"); // sends get values command

    while (i < 200000000) {
      i++;
    } // delay
    i = 0;

    // myPort.write("OK");
    readStatus = "Can't Read";

    if (myPort.read() == 'x') {
      PitchP.setValue(myPort.read() / 100.00f);
      RollP.setValue(myPort.read() / 100.00f);
      YawP.setValue(myPort.read() / 100.00f);

      PitchD.setValue(myPort.read() / 100.00f);
      RollD.setValue(myPort.read() / 100.00f);
      YawD.setValue(myPort.read() / 100.00f);

      PitchPWR.setValue(myPort.read());
      RollPWR.setValue(myPort.read());
      YawPWR.setValue(myPort.read());

      RCcontrol = PApplet.parseChar(myPort.read());
      YawRCon = PApplet.parseChar(myPort.read());

      RollCal.setValue((myPort.read() - 100.00f) / 10.00f);

      if (RCcontrol == '0') {
        buttonRCOff.setColorBackground(green_);
        buttonRCOn.setColorBackground(gray_);
      }
      if (RCcontrol == '1') {
        buttonRCOff.setColorBackground(gray_);
        buttonRCOn.setColorBackground(green_);
      }

      if (YawRCon == '0') {
        buttonYawRC.setColorBackground(gray_);
        buttonYawAut.setColorBackground(green_);
      }
      if (YawRCon == '1') {
        buttonYawRC.setColorBackground(green_);
        buttonYawAut.setColorBackground(gray_);
      }

      readStatus = "Read OK";
    }
  }
Пример #11
0
    public void display() {
      fill(c.white);
      drawWelcome();
      drawName();

      if (!didPressInfo && !didPressStart) {
        b1.display();
        b2.display();
        easy.display();
        medium.display();
        hard.display();
      } else if (didPressInfo && !didPressStart) {
        drawInfo();
        b3.display();
      }

      exit.display();
    }
Пример #12
0
 public void resetAllData() {
   tester.data = "";
   user.data = "";
 }
Пример #13
0
 public void setUserWord(String word) {
   user.data = word;
 }
Пример #14
0
 public void setTesterWord(String word) {
   tester.data = word;
 }
Пример #15
0
 public void RC_ON() {
   buttonRCOff.setColorBackground(gray_);
   buttonRCOn.setColorBackground(green_);
   RCcontrol = '1';
 }
Пример #16
0
 public void Yaw_Auto_Pan() {
   buttonYawRC.setColorBackground(gray_);
   buttonYawAut.setColorBackground(green_);
   YawRCon = '0';
 }
Пример #17
0
    public void mPressed(float mx, float my) {

      if (!didPressInfo) {
        if (b1.isClicked(mx, my)) {
          b1.col = c.gray;
          b2.col = c.white;
          b3.col = c.white;
          didPressInfo = true;
          didPressStart = false;
        } else if (b2.isClicked(mx, my)) {
          b1.col = c.white;
          b2.col = c.gray;
          b3.col = c.white;
          didPressInfo = false;
          didPressStart = true;
        }
      } else if (didPressInfo) {
        if (b3.isClicked(mx, my)) {
          b1.col = c.white;
          b2.col = c.white;
          b3.col = c.gray;
          didPressInfo = false;
          didPressStart = false;
        }
      }

      if (easy.isClicked(mx, my)) {
        easy.col = c.gray;
        medium.col = c.white;
        hard.col = c.white;
        difficulty = 0;
      } else if (medium.isClicked(mx, my)) {
        easy.col = c.white;
        medium.col = c.gray;
        hard.col = c.white;
        difficulty = 1;
      } else if (hard.isClicked(mx, my)) {
        easy.col = c.white;
        medium.col = c.white;
        hard.col = c.gray;
        difficulty = 2;
      }

      if (exit.isClicked(mx, my)) {
        exit();
      }
    }
Пример #18
0
 Menu() {
   easy.col = c.gray;
 }
Пример #19
0
  public void setup() {

    size(600, 280);
    background(75);

    textSize(28);
    fill(0, 120, 170); // blue
    text("EvvGC GUI", 20, 50);
    text(Version, 170, 50);

    // Define colors
    b1 = color(80);
    b2 = color(60);
    c1 = color(80, 80, 80);
    c2 = color(60, 61, 59);

    controlP5 = new ControlP5(this); // initialize the GUI controls

    // List all the available serial ports:
    println(Serial.list());

    commListMax = -1;
    for (int i = 0; i < Serial.list().length; i++) {
      commListMax = i;
    }

    /**
     * ****************************PID
     * cells************************************************************
     */
    PitchP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("PitchP", 0, xPP, yPP, 40, 16));
    PitchP.setColorBackground(gray_);
    PitchP.setMin(0);
    PitchP.setDirection(Controller.HORIZONTAL);
    PitchP.setDecimalPrecision(2);
    PitchP.setMultiplier(0.01f);
    PitchP.setMax(2.54f);

    PitchD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("PitchD", 0, xPD, yPD, 40, 16));
    PitchD.setColorBackground(gray_);
    PitchD.setMin(0);
    PitchD.setDirection(Controller.HORIZONTAL);
    PitchD.setDecimalPrecision(2);
    PitchD.setMultiplier(0.01f);
    PitchD.setMax(1);

    RollP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollP", 0, xRP, yRP, 40, 16));
    RollP.setColorBackground(gray_);
    RollP.setMin(0);
    RollP.setDirection(Controller.HORIZONTAL);
    RollP.setDecimalPrecision(2);
    RollP.setMultiplier(0.01f);
    RollP.setMax(2.54f);

    RollD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollD", 0, xRD, yRD, 40, 16));
    RollD.setColorBackground(gray_);
    RollD.setMin(0);
    RollD.setDirection(Controller.HORIZONTAL);
    RollD.setDecimalPrecision(2);
    RollD.setMultiplier(0.01f);
    RollD.setMax(1);

    YawP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawP", 0, xYP, yYP, 40, 16));
    YawP.setColorBackground(gray_);
    YawP.setMin(0);
    YawP.setDirection(Controller.HORIZONTAL);
    YawP.setDecimalPrecision(2);
    YawP.setMultiplier(0.01f);
    YawP.setMax(2.54f);

    YawD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawD", 0, xYD, yYD, 40, 16));
    YawD.setColorBackground(gray_);
    YawD.setMin(0);
    YawD.setDirection(Controller.HORIZONTAL);
    YawD.setDecimalPrecision(2);
    YawD.setMultiplier(0.01f);
    YawD.setMax(1);

    /**
     * ****************************Power
     * cells************************************************************
     */
    PitchPWR =
        (controlP5.Numberbox)
            hideLabel(controlP5.addNumberbox("PitchPWR", 0, xPPWR, yPPWR, 40, 16));
    PitchPWR.setColorBackground(gray_);
    PitchPWR.setMin(0);
    PitchPWR.setDirection(Controller.HORIZONTAL);
    PitchPWR.setDecimalPrecision(0);
    PitchPWR.setMultiplier(1);
    PitchPWR.setMax(100);

    RollPWR =
        (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollPWR", 0, xRPWR, yRPWR, 40, 16));
    RollPWR.setColorBackground(gray_);
    RollPWR.setMin(0);
    RollPWR.setDirection(Controller.HORIZONTAL);
    RollPWR.setDecimalPrecision(0);
    RollPWR.setMultiplier(1);
    RollPWR.setMax(100);

    YawPWR =
        (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawPWR", 0, xYPWR, yYPWR, 40, 16));
    YawPWR.setColorBackground(gray_);
    YawPWR.setMin(0);
    YawPWR.setDirection(Controller.HORIZONTAL);
    YawPWR.setDecimalPrecision(0);
    YawPWR.setMultiplier(1);
    YawPWR.setMax(100);

    /**
     * ****************************Calibration
     * cells************************************************************
     */
    RollCal =
        (controlP5.Numberbox)
            hideLabel(controlP5.addNumberbox("RollCal", 0, xRollCal, yRollCal, 40, 16));
    RollCal.setColorBackground(gray_);
    RollCal.setMin(-10);
    RollCal.setDirection(Controller.HORIZONTAL);
    RollCal.setDecimalPrecision(1);
    RollCal.setMultiplier(0.2f);
    RollCal.setMax(10);
    buttonZeroRoll = controlP5.addButton("ZERO", 1, 535, 200, 40, 16);
    buttonZeroRoll.setColorBackground(gray_);

    /**
     * **************************Buttons********************************************************************
     */
    buttonWRITE = controlP5.addButton("WRITE", 1, 500, 248, 60, 20);
    buttonWRITE.setColorBackground(gray_);
    buttonREAD = controlP5.addButton("READ", 1, 40, 248, 60, 20);
    buttonREAD.setColorBackground(gray_);

    buttonCONFon = controlP5.addButton("CONFIGon", 1, 400, 10, 60, 60);
    buttonCONFon.setColorBackground(gray_);
    buttonCONFoff = controlP5.addButton("CONFIGoff", 1, 330, 10, 60, 60);
    buttonCONFoff.setColorBackground(gray_);

    buttonP0 = controlP5.addButton("P0", 1, 490, 5, 20, 20);
    buttonP0.setColorBackground(gray_);
    buttonP1 = controlP5.addButton("P1", 1, 490, 30, 20, 20);
    buttonP1.setColorBackground(gray_);
    buttonP2 = controlP5.addButton("P2", 1, 490, 55, 20, 20);
    buttonP2.setColorBackground(gray_);

    buttonRCOff = controlP5.addButton("RC_OFF", 1, 450, 122, 65, 20);
    buttonRCOff.setColorBackground(gray_);
    buttonRCOn = controlP5.addButton("RC_ON", 1, 450, 100, 65, 20);
    buttonRCOn.setColorBackground(gray_);

    buttonYawRC = controlP5.addButton("Yaw_RC_Pan", 1, 520, 100, 75, 20);
    buttonYawRC.setColorBackground(gray_);
    buttonYawAut = controlP5.addButton("Yaw_Auto_Pan", 1, 520, 122, 75, 20);
    buttonYawAut.setColorBackground(gray_);

    buttonCONFoff.setColorBackground(green_);
  }
Пример #20
0
 public void displayStartButton() {
   startButton.display();
 }
Пример #21
0
 public void mPressed(float mx, float my) {
   if (startButton.isClicked(mx, my)) {
     startBool = true;
   }
 }
Пример #22
0
    Levels() {
      quit.col = c.white;

      checkButton.enabled = false;
    }