예제 #1
0
 public void run() {
   try {
     while (läuft) {
       Thread.sleep(1);
       if (verloren) {
         verloren();
       } else {
         if (intro) {
           rot.setIcon(new ImageIcon("files/Minigames/Senso/red_n.png"));
           gruen.setIcon(new ImageIcon("files/Minigames/Senso/green_n.png"));
           blau.setIcon(new ImageIcon("files/Minigames/Senso/blue_n.png"));
           gelb.setIcon(new ImageIcon("files/Minigames/Senso/yellow_n.png"));
           lblVerloren.setText("");
           start.setText("3");
           Thread.sleep(1000);
           start.setText("2");
           Thread.sleep(1000);
           start.setText("1");
           Thread.sleep(1000);
           start.setLocation(start.getX() - 20, start.getY());
           start.setText("Los!");
           Thread.sleep(250);
           start.setText("");
           start.setLocation(start.getX() + 20, start.getY());
           rot.setIcon(new ImageIcon("files/Minigames/Senso/red_0.png"));
           gruen.setIcon(new ImageIcon("files/Minigames/Senso/green_0.png"));
           blau.setIcon(new ImageIcon("files/Minigames/Senso/blue_0.png"));
           gelb.setIcon(new ImageIcon("files/Minigames/Senso/yellow_0.png"));
           intro = false;
           neu = true;
         }
         if (wiedergeben && !verloren) {
           Thread.sleep(500);
           alteFarbe();
         } else if (neu && !verloren) neueFarbe();
         if (!wiedergeben && !neu) {
           String s = "Noch ";
           vKlicks = runde - klick;
           if (vKlicks >= 1) s = s + String.valueOf(vKlicks);
           else s = "";
           klicks.setText(s);
         } else klicks.setText("");
       }
     }
   } catch (Exception e) {
   }
 }
예제 #2
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == start) {
      t.start();

      result.setVisible(false);
      scoreValue = 0;
      speed.setText("SPEED " + 40); // this is starting speeed
    }

    if (count % 10 == 0) {
      carNo = CarRace.randInt();

      if (carNo == 1 && flag1 == 0) {
        one.setVisible(true);
        one.setBounds(120, 100, 120, 70);
        pos1 = 100;
        flag1 = 1;
      }
      if (carNo == 2 && flag2 == 0) {
        two.setVisible(true);
        two.setBounds(240, 100, 120, 70);
        pos2 = 100;
        flag2 = 1;
      }

      if (carNo == 3 && flag3 == 0) {
        three.setVisible(true);
        three.setBounds(360, 100, 120, 70);
        pos3 = 100;
        flag3 = 1;
      }
    }

    count++;
    if (count >= 1000) count = 0;

    if (one.isVisible() == true) {
      one.setBounds(120, pos1, 120, 70);
      pos1 += 10;
      if (pos1 > 520) {
        flag1 = 0;
        one.setVisible(false);
      }
    }

    if (two.isVisible() == true) {
      two.setBounds(240, pos2, 120, 70);
      pos2 += 10;
      if (pos2 > 520) {
        flag2 = 0;
        two.setVisible(false);
      }
    }

    if (three.isVisible() == true) {
      three.setBounds(360, pos3, 120, 70);
      pos3 += 10;
      if (pos3 > 520) {
        flag3 = 0;
        three.setVisible(false);
      }
    }

    if (one.getY() + 70 == car.getY() && car.getX() == 120) {
      t.stop();
      result.setText(" SCORE " + scoreValue);
      result.setVisible(true);
    } else if (two.getY() + 70 == car.getY() && car.getX() == 240) {
      t.stop();
      result.setText(" SCORE " + scoreValue);
      result.setVisible(true);
    } else if (three.getY() + 70 == car.getY() && car.getX() == 360) {
      t.stop();
      result.setText(" SCORE " + scoreValue);
      result.setVisible(true);
    }

    scoreValue += 1;
    score.setText("score " + scoreValue);

    int m = 160 - x;
    if (m < 0) m = 0;
    speed.setText("SPEED " + m);
  }