コード例 #1
0
 public void draw() {
   if (game.screen == 0) { // checks if on starting screen
     game.startScreen(); // generates starting screen
   } else if (game.screen == 1) { // checks if on game screen
     game.gameScreen(); // generates game screen
   }
 }
コード例 #2
0
  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
      }
    }
  }
コード例 #3
0
  public void setup() {

    game = new Game(); // sets new game
    fill(0, 0, 0); // sets background
    game.screen = 0; // sets game to starting screen
  }