Exemple #1
0
 /**
 * Initialization
 */
 public void begin(){
   int bx = 0;
   int by = 0;
   int px = 0;
   int py = 0;
   for(int i = 0; i < IMG_NUM; i++){
     
     bx = BOARD_MARGIN_X + SIDE_LENGTH * (i % PIECES_PER_COL);
     by = BOARD_MARGIN_Y + SIDE_LENGTH * (i / PIECES_PER_ROW);
     px = PUZZLE_OFFSET + PUZZLE_SPACING * 
         (i % PIECES_PER_COL + 1) + SIDE_LENGTH * 
         (i % PIECES_PER_COL);
     py = PUZZLE_SPACING * (i / PIECES_PER_ROW + 1) + 
         SIDE_LENGTH * (i / PIECES_PER_ROW);
     //x,y coordination of puzzle & board pieces
     
     img[i] = getImage("p" + i + ".jpg");
     bLocation[i] = new Location(bx, by);
     pLocation[i] = new Location(px, py);
   }
   text = new Text("YOU WIN!!!", TEXT_X,
       bLocation[TEXT_LOCATION].getY(), canvas);
   text.setFontSize(FONT_SIZE);
   text.setBold(true);
   text.setColor(Color.GREEN);
   text.hide();
   
   //pass pieces objects into arrays
   for(int i = 0; i < IMG_NUM; i++){
     bp[i] = new BoardPiece(img[i], i, bLocation[i], canvas);
     pp[i] = getRandomPiece(pLocation[i], canvas);
   }
   
 }
Exemple #2
0
  public void startGame() {

    bread.loop();
    gameOn = true;
    yellow.removeFromCanvas();
    pink.removeFromCanvas();
    purple.removeFromCanvas();
    green.removeFromCanvas();
    grey.removeFromCanvas();
    button.removeFromCanvas();
    author.removeFromCanvas();
    title.removeFromCanvas();

    start = new Location(canvas.getWidth() / 2, canvas.getHeight() / 2);
    theFish = new TheFish(fishPic, start, canvas, 50, 25);
    ocean = new Ocean(angryFishPic, angryFishL, bubblePic, canvas, theFish);

    score = new Text("Score: " + currentScore, 0, 0, canvas);
    score.setFontSize(16);
    score.moveTo((canvas.getWidth() - score.getWidth()) / 2, 50);

    bubbles = new Bubbles(dopeBubble, canvas);
  }
Exemple #3
0
 // Change the font size used
 public void setTextSize(int size) {
   message.setFontSize(size);
   positionContents();
 }