Esempio n. 1
0
  // Draw
  public void drawStatistics(Graphics g) {
    g.setColor(Color.BLACK);
    g.setFont(new Font("Courier", Font.BOLD, 20));
    g.drawString("Player: " + name, 10, 30);
    g.drawString("Rank: " + rank, 10, 50);
    g.drawString("Time: " + minute + ":" + second + ":" + milisecond, 10, 70);
    g.drawString("Speed: " + self.getCurrentSpeed(), 10, 90);

    int percent = (int) ((self.getTotalDistanceTraveled() * 100 / map.distancePerLap()));
    g.drawString("Match Finished: " + percent + "%", 10, 110);
  }
Esempio n. 2
0
 // Calculate
 public void run() {
   while (true) {
     //			System.out.println("sdf");
     if (self.getTotalDistanceTraveled() > rival.getTotalDistanceTraveled()) {
       rank = "1";
     } else if (self.getTotalDistanceTraveled() < rival.getTotalDistanceTraveled()) {
       rank = "2";
     } else rank = "draw";
     try {
       sleep(10);
     } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     if (milisecond == 99) {
       if (second == 59) {
         minute++;
         second = 0;
       } else second++;
       milisecond = 0;
     } else milisecond++;
   }
 }