示例#1
0
  /**
   * Gets a random color for the background elements
   *
   * @return The color
   */
  public int getBackgroundColor() {
    if (colors == null) return -1;

    // Get a color int from the hex color
    int base = Util.hex2Color(colors.get(4));

    // Return a slightly modified color
    return Util.getSimilarColor(base, 0.05f);
  }
示例#2
0
  /**
   * Gets a random color for a bubble
   *
   * @return The color
   */
  public int getBubbleColor() {
    if (colors == null) return -1;

    // Get the third or fourth color
    int randomColor = new Random().nextInt(2) + 2;
    // Get a color int from the hex color
    int base = Util.hex2Color(colors.get(randomColor));

    // Return a slightly modified color
    return Util.getSimilarColor(base);
  }
示例#3
0
  /**
   * Gets a random color for a triangle / door / spike
   *
   * @return The color
   */
  public int getTriangleColor() {
    if (colors == null) return -1;

    // Get the first or second color
    int randomColor = new Random().nextInt(2);
    // Get a color int from the hex color
    int base = Util.hex2Color(colors.get(randomColor));

    // Return a slightly modified color
    return Util.getSimilarColor(base);
  }
示例#4
0
  /** Creates the background shapes */
  protected void makeBackground() {
    int backgroundShapes = (int) (new Random().nextFloat() * 50) + 70;
    for (int i = 0; i < backgroundShapes; ++i) {
      Random random = new Random();

      // Get random values
      float y = 4 + random.nextFloat() * 2;
      float x = i + random.nextFloat() * 2 - 5;
      float size = random.nextFloat() * 8;
      float speed = random.nextFloat() * 0.02f - 0.01f;

      // Every second element is placed at the bottom
      if (i % 2 == 0) {
        y *= -1;
      }

      // Create the rectangle
      Rectangle rect = new Rectangle(x, y, size, speed);

      // Set the color
      float[] colors = Util.getColorParts(getBackgroundColor());
      rect.setColor(colors[0], colors[1], colors[2], 1);

      // Add the element
      backgroundElements.add(rect);
    }
  }
示例#5
0
 public void drawBackground(GL10 gl) {
   int color = Util.hex2Color(colors.get(4));
   float[] colors = Util.getColorParts(color);
   gl.glClearColor(colors[0], colors[1], colors[2], 1);
 }