Ejemplo n.º 1
0
 private GLabel prompt(String endGame) {
   GLabel prompt = new GLabel(endGame);
   prompt.setFont("Times-Bold-50");
   double x = (WIDTH - prompt.getWidth()) / 2;
   double y = HEIGHT * 4.0 / 5.0;
   prompt.setLocation(x, y);
   return prompt;
 }
 /** The method accepts a string and displays the green text in the center of the screen */
 private GLabel createMessage(String message) {
   GLabel text = new GLabel(message);
   text.setFont("Arial Black-20");
   text.setColor(Color.GREEN);
   double x = (WIDTH - text.getWidth()) / 2;
   double y = (HEIGHT - text.getDescent()) / 2;
   text.setLocation(x, y);
   add(text);
   return text;
 }
 /** Displays the amount of points on the screen in text form */
 private GLabel createScore(String score) {
   GLabel text = new GLabel(score);
   text.setFont("Arial Black-12");
   text.setColor(Color.black);
   double x = (WIDTH - text.getWidth()) / 2;
   double y = HEIGHT - text.getDescent();
   text.setLocation(x, y);
   add(text);
   return text;
 }
Ejemplo n.º 4
0
 public GLabel makeLetterLabel(int numDivs) {
   boolean get = randgen.nextBoolean();
   String ga;
   if (get) ga = "G";
   else ga = "A";
   GLabel getOrAvoid = new GLabel(ga);
   getOrAvoid.setFont(new Font("Cambria", Font.BOLD, 24));
   double locx = randgen.nextDouble(INDENT, getWidth() - getOrAvoid.getWidth());
   int whichdiv = randgen.nextInt(1, numDivs);
   double locy = whichdiv * getHeight() / numDivs;
   getOrAvoid.setLocation(locx, locy);
   return getOrAvoid;
 }
Ejemplo n.º 5
0
 private GLabel showLifeCount(int life) {
   GLabel lifeCount = new GLabel("Life Count: " + life);
   lifeCount.setFont("Times-15");
   lifeCount.setLocation(10, lifeCount.getAscent() + 10);
   return lifeCount;
 }