示例#1
1
 static void rand() // 중복되지 않는 랜덤 숫자배열 두개 만들기
     {
   int su = 0; // 난수 발생시 저장할 변수
   boolean bDash = false; // 중복여부 확인
   for (int i = 0; i < 75; i++) {
     bDash = true;
     while (bDash) // 난수발생, 중복 학인
     {
       su = (int) (Math.random() * 75) + 1; // 판 크기+10개(상대가 못맞출 수도 있게)의 난수 입력
       bDash = false;
       for (int j = 0; j < i; j++) {
         if (numArr1[j] == su) {
           bDash = true; // 중복이 있으면 멈추고 while문을 다시 수행(랜덤값을 다시 줌)
           break;
         }
       }
     }
     numArr1[i] = su;
   }
   for (int i = 0; i < 75; i++) {
     bDash = true;
     while (bDash) // 난수발생, 중복 학인
     {
       su = (int) (Math.random() * 75) + 1; // 판 크기+10개(상대가 못맞출 수도 있게)의 난수 입력
       bDash = false;
       for (int j = 0; j < i; j++) {
         if (numArr2[j] == su) {
           bDash = true; // 중복이 있으면 멈추고 while문을 다시 수행(랜덤값을 다시 줌)
           break;
         }
       }
     }
     numArr2[i] = su;
   }
 }
  /** Start the background thread. */
  public void start() {
    // create a random list of cities

    cities = new City[TravelingSalesman.CITY_COUNT];
    for (int i = 0; i < TravelingSalesman.CITY_COUNT; i++) {
      cities[i] =
          new City(
              (int) (Math.random() * (getBounds().width - 10)),
              (int) (Math.random() * (getBounds().height - 60)));
    }

    // create the initial chromosomes

    chromosomes = new Chromosome[TravelingSalesman.POPULATION_SIZE];
    for (int i = 0; i < TravelingSalesman.POPULATION_SIZE; i++) {
      chromosomes[i] = new Chromosome(cities);
      chromosomes[i].setCut(cutLength);
      chromosomes[i].setMutation(TravelingSalesman.MUTATION_PERCENT);
    }
    Chromosome.sortChromosomes(chromosomes, TravelingSalesman.POPULATION_SIZE);

    // start up the background thread
    started = true;
    map.update(map.getGraphics());

    generation = 0;

    if (worker != null) worker = null;
    worker = new Thread(this);
    // worker.setPriority(Thread.MIN_PRIORITY);
    worker.start();
  }
示例#3
0
  private void spawnRandomers() {
    for (int i = 0; i < randomN; i++) {
      float x = (float) Math.random() * width;
      float y = (float) Math.random() * height;
      float r =
          (float)
              Math.sqrt(
                  Math.pow(((Player) players.get(0)).getX() - x, 2)
                      + Math.pow(((Player) players.get(0)).getY() - x, 2));

      while (r < distanceLimit) {
        x = (float) Math.random() * width;
        y = (float) Math.random() * height;
        r =
            (float)
                Math.sqrt(
                    Math.pow(((Player) players.get(0)).getX() - x, 2)
                        + Math.pow(((Player) players.get(0)).getY() - y, 2));
      }

      enemies.add(new EnemyTypes.Random(x, y, 0.5f, borders));
    }

    spawnRandomersB = false;
  }
  /**
   * Spawn a character on the map
   *
   * @param MiX Minimum X value
   * @param MiY Minimum Y value
   * @param MaX Maximum X value
   * @param MaY Maximum Y value
   */
  public void Spawn(int MiX, int MiY, int MaX, int MaY) {
    double Nx = 0, Ny = 0;

    // Random coordinate
    Nx = Math.random() * MaX + MiX;
    Ny = Math.random() * MaY + MiY;

    // Store block number
    int BNum = MAP.elementAt(0).getBlockNum(Nx + W / 2, Ny + H / 2);

    // if invalid block number
    if (BNum == -1) {
      Spawn(MiX, MiY, MaX, MaY);
    }

    // if invalid surface
    else if (!isValidSurface(MAP.elementAt(0).Fill[BNum])) {
      Spawn(MiX, MiY, MaX, MaY);
    }

    // if colliding with something
    else if (this.Collision(Nx + W / 2, Ny + H / 2)) {
      Spawn(MiX, MiY, MaX, MaY);
    } else {
      X = Nx;
      Y = Ny;
    }
  }
示例#5
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (firstClick) {
      firstClick = false;
      lastIcon = buttons[0][0].getIcon();
      buttons[0][0].setIcon(null);
      for (int i = 0; i < 10000; i++) {
        int zufallY = (int) ((Math.random() * YY) + 0);
        int zufallX = (int) ((Math.random() * XX) + 0);
        switchButton(zufallY, zufallX);
      }
      // ToDo: unwiederrufbare Operationen vermeiden?
      // funktion klären und abfangen
      /*while(lastButton % XX != 0)
          switchButton(lastButton-1);
      while (lastButton != "00")
          switchButton(lastButton-XX);*/

    } else {
      PuzzButton tmp = (PuzzButton) e.getSource();
      int posY = tmp.getPosY();
      int posX = tmp.getPosX();

      switchButton(posY, posX);
      if (isDone()) {
        buttons[0][0].setIcon(lastIcon);
        firstClick = true;
      }
    }
  }
示例#6
0
  // Proceso para posicionar las imagenes en el concentrece
  public void cargarImagenes() {
    int x, y = 0;
    int numero = -1;
    double x1, y1 = 0;
    ficha = new int[a][b];
    // Incializacion de la matriz entera en -1
    for (int i = 0; i < getA(); i++) {
      for (int j = 0; j < getB(); j++) {
        ficha[i][j] = -1;
      }
    }

    // Proceso de introduccion de imagenes en posiciones aleatorias para
    // obtener mas variaciones del juego
    for (int i = 0; i < getA(); i++) {
      for (int j = 0; j < getB(); j++) {
        do {
          x1 = Math.random() * getA();
          y1 = Math.random() * getB();
          x = (int) x1;
          y = (int) y1;
        } while (ficha[x][y] != -1);
        numero++;
        if (numero == getC()) {
          numero = 0;
        }
        ficha[x][y] = numero;
        parejas[i][j].setIcon(vacio);
      }
    }
  }
示例#7
0
  protected void moveBall() {
    // System.out.println("I'm in the moveBall() function!");
    int width = getWidth();
    int height = getHeight();
    int min, max, randomX, randomY;
    min = 0;
    max = 200;
    randomX = min + (int) (Math.random() * ((max - min) + 1));
    randomY = min + (int) (Math.random() * ((max - min) + 1));
    // System.out.println(randomX + ", " + randomY);

    Rectangle ballBounds = ball.getBounds();
    //      //System.out.println(ballBounds.x + ", " + ballBounds.y);
    //      if (ballBounds.x + randomX < 0) {
    //          randomX = 200;
    //      } else if (ballBounds.x + ballBounds.width + randomX > width) {
    //          randomX = -200;
    //      }
    //      if (ballBounds.y + randomY < 0) {
    //          randomY = 200;
    //      } else if (ballBounds.y + ballBounds.height + randomY > height) {
    //          randomY = -200;
    //      }

    ballBounds.x = randomX;
    ballBounds.y = randomY;
    _ballXpos = ballBounds.x;
    _ballYpos = ballBounds.y;
    ball.setFrame(ballBounds);
    thePlacebo.repaint();
  }
 // -------------------------------------------------------------------------------------------------------------------------------------------------------
 // Decorations
 public void newDecos() {
   int prob = (int) (Math.random() * 100); // randomly spawnst he decoration
   if (prob == 1) {
     if (decoList.size() < 1) {
       int prob2 = (int) (Math.random() * 2);
       if (prob2 == 1) { // right side or left side
         decoList.add(new Decorations(-700, (int) (backy * 0.1) % 23080, false));
       } else {
         decoList.add(new Decorations(-700, (int) (backy * 0.1) % 23080, true));
       }
     }
   }
   Boolean check = true;
   for (Decorations i : decoList) {
     if (i.getYTop() >= 2000) {
       check = false;
       break;
     }
   }
   if (check == false
       && decoList.size()
           > 0) { // theres only on in the lsit but for consitency we kept it as a list
     decoList.remove(0);
   }
 }
示例#9
0
  public void reset() {

    // init the location of the rocket to the center.
    rocketXPos = getWidth2() / 2;
    rocketYPos = getHeight2() / 2;
    // rocket direction
    rocketRight = true;
    // rocket speed.
    rocketXSpeed = 0;
    rocketYSpeed = 0;
    rocketMaxSpeed = 10;
    // rocket lives
    rocketLife = 3;
    // star position.
    starXPos = new int[numStars];
    starYPos = new int[numStars];
    starActive = new boolean[numStars];

    for (int index = 0; index < numStars; index++) {
      starXPos[index] = (int) (Math.random() * getWidth2());
      starYPos[index] = (int) (Math.random() * getHeight2());
      starActive[index] = true;
    }
    // score stuff
    score = 0;
    // missile stuff
    missile = new Missile[Missile.numMissile];
    for (int index = 0; index < missile.length; index++) {
      missile[index] = new Missile();
    }
    Missile.currentIndex = 0;
    starHit = -1;
    gameOver = false;
  }
示例#10
0
  public static void main(String[] args) {
    Plot2DPanel p = new Plot2DPanel();

    double[] X = new double[10];
    double[] Y = new double[10];
    for (int j = 0; j < X.length; j++) {
      X[j] = j;
      Y[j] = Math.random();
    }
    p.addStaircasePlot("toto", X, Y);

    new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Color[] c = new Color[10];

    p = new Plot2DPanel();

    X = new double[10];
    Y = new double[10];
    for (int j = 0; j < X.length; j++) {
      X[j] = j;
      Y[j] = Math.random();
      c[j] = new Color((int) (Math.random() * 0x1000000));
    }
    p.addStaircasePlot("toto", c, X, Y);

    new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
示例#11
0
 private void addTile() {
   List<Tile> list = availableSpace();
   if (!availableSpace().isEmpty()) {
     int index = (int) (Math.random() * list.size()) % list.size();
     Tile emptyTime = list.get(index);
     emptyTime.value = Math.random() < 0.9 ? 2 : 4;
   }
 }
 // Starts this die rolling
 public void roll() {
   super.roll();
   int width = tableRight - tableLeft;
   int height = tableBottom - tableTop;
   xCenter = tableLeft;
   yCenter = tableTop + height / 2;
   xSpeed = width * (Math.random() + 1) * speedFactor;
   ySpeed = height * (Math.random() - .5) * 2. * speedFactor;
 }
示例#13
0
 public Ball(Color c, Bar b) {
   color = c;
   bar = b;
   double x = (Cwiczenie5_4.SIZE.width - SIZE) * Math.random();
   double y = (Cwiczenie5_4.SIZE.height - Bar.SIZE.height - SIZE) * Math.random();
   pos = new Point((int) x, (int) y);
   int d = MAX_VEL - MIN_VEL;
   dy = (-1) * (int) (d * Math.random() + MIN_VEL);
   dx = (int) (2 * MAX_VEL * Math.random() - MAX_VEL);
 }
  public void addParticle(int x, int y) {
    // TODO configurable
    int dx, dy;
    dx = (int) (Math.random() * 4) * (Math.random() > 0.5 ? -1 : 1);
    dy = (int) (Math.random() * -3 - 1);

    int size = (int) (Math.random() * 3 + 1);
    int life = 15;
    final Particle e = new Particle(x, y, dx, dy, size, life, JBColor.darkGray);
    particles.add(e);
  }
示例#15
0
 public void animate(float[] pts, float[] deltas, int index, int limit) {
   float newpt = pts[index] + deltas[index];
   if (newpt <= 0) {
     newpt = -newpt;
     deltas[index] = (float) (Math.random() * 3.0 + 2.0);
   } else if (newpt >= (float) limit) {
     newpt = 2.0f * limit - newpt;
     deltas[index] = -(float) (Math.random() * 3.0 + 2.0);
   }
   pts[index] = newpt;
 }
示例#16
0
  // experimental
  // ====================================================================
  // ====================================================================
  // ====================================================================
  private void readAndDrawBIGGraph(String file) {
    // behövs inte än
    // @TODO
    // hur rita flera linjer mellan 2 noder? (för flera linjer)
    // reading of the graph should be done in the graph itself
    // it should be possible to get an iterator over nodes and one over edges
    // read in all the stops and lines and draw the lmap
    Scanner indata = null;
    // insert into p-queue to get them sorted
    names = new PriorityQueue<String>();
    try {
      // Read stops and put them in the node-table
      // in order to give the user a list of possible stops
      // assume input file is correct
      indata = new Scanner(new File(file + "-stops.txt"), "ISO-8859"); //
      while (indata.hasNext()) {
        String hpl = indata.next().trim();
        int xco = indata.nextInt();
        int yco = indata.nextInt();
        noderna.add(new BusStop(hpl, xco, yco));
        names.add(hpl);
        // Draw
        // this is a fix: fixa att Kålltorp och Torp är samma hållplats
        if (hpl.equals("Torp")) {
          xco += 11;
          hpl = "   / Torp";
        }
        karta.drawString(hpl, xco, yco, DrawGraph.Layer.BASE);
      }
      indata.close();

      //  Read in the lines and add to the graph
      indata = new Scanner(new File(file + "-lines.txt"), "ISO-8859");
      grafen = new DirectedGraph<BusEdge>(noderna.noOfNodes());
      Color color =
          new Color((float) Math.random(), (float) Math.random(), (float) Math.random()); //
      String lineNo = "1"; //
      while (indata.hasNext()) { // assume lines are correct
        int from = noderna.find(indata.next()).getNodeNo();
        int to = noderna.find(indata.next()).getNodeNo();
        grafen.addEdge(new BusEdge(from, to, indata.nextInt(), lineNo));
        indata.nextLine(); // skip rest of line
        // Draw
        BusStop busFrom = noderna.find(from);
        BusStop busTo = noderna.find(to);
        karta.drawLine(
            busFrom.xpos, busFrom.ypos, busTo.xpos, busTo.ypos, color, 2.0f, DrawGraph.Layer.BASE);
      }
      indata.close();
    } catch (FileNotFoundException fnfe) {
      throw new RuntimeException(" Indata till busshållplatserna saknas");
    }
    karta.repaint();
  } // end readAndDrawBIGGraph
  // Draws this die when rolling with a random number of dots
  private void drawRolling(Graphics g) {
    int x = xCenter - dieSize / 2 + (int) (3 * Math.random()) - 1;
    int y = yCenter - dieSize / 2 + (int) (3 * Math.random()) - 1;
    g.setColor(Color.RED);

    if (x % 2 != 0) g.fillRoundRect(x, y, dieSize, dieSize, dieSize / 4, dieSize / 4);
    else g.fillOval(x - 2, y - 2, dieSize + 4, dieSize + 4);

    Die die = new Die();
    die.roll();
    drawDots(g, x, y, die.getNumDots());
  }
示例#18
0
 /**
  * The run method just posts messages to the transcript at random intervals of 2 to 10 seconds.
  */
 public void run() {
   //
   postMessage("RECEIVED: Hey, hello there! Nice to chat with you.");
   while (running) {
     try {
       // Wait a random time from 2000 to 10000 milliseconds.
       Thread.sleep(2000 + (int) (8000 * Math.random()));
     } catch (InterruptedException e) {
     }
     int msgNum = (int) (Math.random() * incomingMessages.length);
     postMessage("RECEIVED: " + incomingMessages[msgNum]);
   }
 }
示例#19
0
 private void spawnBomb() {
   float x, y;
   for (int i = 0; i < bombN; i++) {
     if (Math.random() > .5) { // top/bottom
       y = (Math.random() > .5) ? borders[1] : borders[3];
       x = (float) Math.random() * borders[2] - borders[0]; // width
     } else {
       x = (Math.random() > .5) ? borders[0] : borders[2];
       y = (float) Math.random() * borders[3] - borders[1]; // height
     }
     enemies.add(new EnemyTypes.Bomb(x, y, 1f, borders, scbInstance));
   }
 }
示例#20
0
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub

    width = frame.getWidth();
    height = frame.getHeight();
    sizeControl.width = width;
    sizeControl.height = height;

    if (info.pressed == true && !showGuide) {
      showGuide = true;
    }

    if (back.pressed == true && showGuide) {
      showGuide = false;
    }

    go.x = width / 2;
    go.y = height / 2;
    info.x = width / 2;
    info.y = height / 2 + 150;
    back.x = 3 * width / 4;
    back.y = height / 2 + 150;

    for (int i = 0; i < boomList.size(); i++) {
      boomList.get(i).updatePosition();
      if (Integer.parseInt(boomList.get(i).toString()) <= 0) {
        boomList.remove(i);
      } else {
        for (int ii = 0; ii < gravList.size(); ii++) {
          gravList.get(ii).pull(boomList.get(i));
          if (boomList.get(i).collide(gravList.get(ii))) {
            boomList.remove(i);
          }
        }
      }
    }

    count--;
    if (count <= 0) {

      double rand1 = Math.random();
      double rand2 = Math.random();
      for (int ii = 0; ii < num; ii++) {
        boomList.add(new boom(rand1 * width, rand2 * height));
      }
      count = delay;
    }

    repaint();
  }
示例#21
0
  private void levelSetup() {
    reset();

    switch (level) {
      case 1:
        distance = 600;
        monsterN = 0;
        randomN = 0;
        rainN = 30;
        defaultDistance = 600;
        timeLast = 10000;
        spawnCircleB = true;
        break;
      case 2:
        distance = 600;
        monsterN = 0;
        randomN = 30;
        rainN = 30;
        defaultDistance = 600;
        timeLast += 10000;
        spawnCircleB = true;
        break;
      case 3:
        distance = 600;
        monsterN = 30;
        randomN = 0;
        rainN = 0;
        defaultDistance = 600;
        timeLast += 10000;
        spawnCircleB = true;
        break;
      default:
        distance = (float) (Math.random() * 200 + 400 - level * 5);
        monsterN = (int) (Math.random() * 25 + 10 + level);
        randomN = (int) (Math.random() * 25 + 10 + level);
        rainN = (int) (Math.random() * 10 + 10 + level);
        defaultDistance = distance;
        timeLast += 5000 + level * 1000;
        spawnCircleB = true;
    }

    monsterN *= monsterMultiplier;
    randomN *= monsterMultiplier;
    spawnMonsterB = true;
    spawnRandomersB = true;
    spawnIncrease = true;
    spawnRainB = true;
  }
示例#22
0
    public void Array(int size) {

      int n;
      char s = 'a';
      String text = "\nRagged array: ";

      char[][] array = new char[size][];

      // Add rows to array
      for (int k = 0; k < size; k++) {
        n = 1 + (int) (Math.random() * 8);
        array[k] = new char[n];
      }
      // Fill out the rows
      for (int i = 0; i < array.length; i++) {

        text += "\n|";

        for (int j = 0; j < array[i].length; j++) {
          array[i][j] = s;
          s++;
          text += array[i][j] + " | ";
        }
      }

      System.out.print(text);
      // JOptionPane.showMessageDialog(null, text); //doesn't work...
    }
示例#23
0
    public int FindRandomSize(int max, int min) {

      int range = Math.abs(max - min) + 1;
      int random_number = (int) (Math.random() * range) + (min <= max ? min : max);

      return random_number;
    }
示例#24
0
 public void blockgen() {
   Component temporaryLostComponent = null;
   pos[0] = 0;
   pos[1] = 1;
   rand = (int) (Math.floor(Math.random() * 7 + 1));
   centralx = 4;
   centraly = 0;
   System.out.print(rand);
   if ((b[4 + prof[pos[0]][0][rand - 1].x][prof[pos[0]][0][rand - 1].y].getBackground()
           == Color.DARK_GRAY)
       && (b[4 + prof[pos[0]][1][rand - 1].x][prof[pos[0]][1][rand - 1].y].getBackground()
           == Color.DARK_GRAY)
       && (b[4 + prof[pos[0]][2][rand - 1].x][prof[pos[0]][2][rand - 1].y].getBackground()
           == Color.DARK_GRAY)
       && (b[4 + prof[pos[0]][3][rand - 1].x][prof[pos[0]][3][rand - 1].y].getBackground()
           == Color.DARK_GRAY)) {
     b[4 + prof[pos[0]][0][rand - 1].x][prof[pos[0]][0][rand - 1].y].setBackground(rnd[rand - 1]);
     b[4 + prof[pos[0]][1][rand - 1].x][prof[pos[0]][1][rand - 1].y].setBackground(rnd[rand - 1]);
     b[4 + prof[pos[0]][2][rand - 1].x][prof[pos[0]][2][rand - 1].y].setBackground(rnd[rand - 1]);
     b[4 + prof[pos[0]][3][rand - 1].x][prof[pos[0]][3][rand - 1].y].setBackground(rnd[rand - 1]);
     go();
   } else {
     JOptionPane.showMessageDialog(
         temporaryLostComponent, "Game Over! You cleared " + rowsclrd + " rows, well done!");
     System.exit(0);
   }
 }
示例#25
0
  public void go() {
    setUpGui();

    try {

      Sequencer sequencer = MidiSystem.getSequencer();
      sequencer.open();
      // make a sequencer and open
      sequencer.addControllerEventListener(m1, new int[] {127});
      Sequence seq = new Sequence(Sequence.PPQ, 4);
      Track track = seq.createTrack();

      int r = 0;
      for (int i = 0; i < 300; i += 4) {

        r = (int) ((Math.random() * 50) + 1);
        track.add(makeEvent(144, 1, r, 100, i));
        track.add(makeEvent(176, 1, 127, 0, i));
        track.add(makeEvent(128, 1, r, 100, i + 2));
      } // end loop

      sequencer.setSequence(seq);
      sequencer.start();
      sequencer.setTempoInBPM(120);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  } // close method
示例#26
0
  /** Checks if a message should be passed up, or not */
  protected boolean shouldDropUpMessage(
      @SuppressWarnings("UnusedParameters") Message msg, Address sender) {
    if (discard_all && !sender.equals(localAddress())) return true;

    if (ignoredMembers.contains(sender)) {
      if (log.isTraceEnabled()) log.trace(localAddress + ": dropping message from " + sender);
      num_up++;
      return true;
    }

    if (up > 0) {
      double r = Math.random();
      if (r < up) {
        if (excludeItself && sender.equals(localAddress())) {
          if (log.isTraceEnabled()) log.trace("excluding myself");
        } else {
          if (log.isTraceEnabled()) log.trace(localAddress + ": dropping message from " + sender);
          num_up++;
          return true;
        }
      }
    }

    return false;
  }
示例#27
0
  public Object down(Message msg) {
    Address dest = msg.getDest();
    boolean multicast = dest == null;

    if (msg.getSrc() == null) msg.setSrc(localAddress());

    if (discard_all) {
      if (dest == null || dest.equals(localAddress())) loopback(msg);
      return null;
    }

    if (!multicast && drop_down_unicasts > 0) {
      drop_down_unicasts = Math.max(0, drop_down_unicasts - 1);
      return null;
    }

    if (multicast && drop_down_multicasts > 0) {
      drop_down_multicasts = Math.max(0, drop_down_multicasts - 1);
      return null;
    }

    if (down > 0) {
      double r = Math.random();
      if (r < down) {
        if (excludeItself && dest != null && dest.equals(localAddress())) {
          if (log.isTraceEnabled()) log.trace("excluding itself");
        } else {
          log.trace("dropping message");
          num_down++;
          return null;
        }
      }
    }
    return down_prot.down(msg);
  }
  // FUNCTION TO GENERATE A STRING OF 10 ADDRESS REFERENCES
  public void autoGenerateString() {
    int random;

    for (int i = 0; i < 10; i++) {

      // RANDOMLY SELECT AN INDEX BETWEEN 0 AND 255
      random = (int) (Math.random() * 256);

      // ADD THE ADDRESS AT THIS INDEX IN ARRAY addresses TO THE LIST OF ADDRESS REFERENCE STRINGS
      //	listData[i] = addresses[random];
      listData.add(addresses[random]);
    }

    // ADD THIS LIST TO THE LISTBOX
    addRefStrList.setListData(listData);

    // ENABLE THE Next BUTTON AND DISABLE Back BUTTON
    //		moveStatus = 0;
    next.setEnabled(true);
    back.setEnabled(false);

    // UPDATE THE PROGRESS FIELD
    tProgress.setText(
        "We have automatically generated an address string of 10 addresses for you to work with."
            + "\nClick on \"Next\" to continue.");
  } // END FUNCTION autoGenerateString
示例#29
0
 /**
  * Constructs a Sorter.
  *
  * @param values the array to be sorted
  * @param comp the component on which to display the sorting progress
  */
 public Sorter(ArrayComponent comp) {
   values = new Double[VALUES_LENGTH];
   for (int i = 0; i < values.length; i++) values[i] = new Double(Math.random());
   this.component = comp;
   this.gate = new Semaphore(1);
   this.run = false;
 }
示例#30
0
  /** Setzt alle Spielparameter zurück und verteilt die Spieler entlang der Main-Ebene */
  public void restartGame() {
    for (int c = 1; c < player.length; c++) {
      if (player[c] != null) {
        player[c].x = (int) (Math.random() * (ebenen[0][1] - ebenen[0][0]) + ebenen[0][0]);
        player[c].y = 0;
        player[c].health = 100;
        player[c].jumpheigth = 200;
        player[c].speed = 5;
        player[c].sperrzeit = 40;
        player[c].freezeControls = false;
        gamerunner.neu = false;
        gamerunner.schonneu = true;
        player[c].amstartwarten = 42;
        player[c].perkzählerjump = -1;
        player[c].perkzählerrun = -1;
        player[c].perkzählershoot = -1;
        player[c].boomRight = 0;
        player[c].boomUp = 0;
        player[c].boomLeft = 0;
        gamerunner.wellenModus.wAnzeige = -1;
        gamerunner.wellenModus.wNeu = false;
        gamerunner.wellenModus.nNeu = false;
        gamerunner.storyModus.amanfang = true;
        gamerunner.wellenModus.amanfang = true;
      } // end of if
    } // end of for

    for (int c = 0; c < gamerunner.shot.length; c++) {
      gamerunner.shot[c] = null;
      DamageLogig.shot[c] = null;
    } // end of for
    DamageLogig.counter = 0;
  }