Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

New to processing and trying to figure out how to rotate a raindrop shape.

$
0
0

I just started a class on this and am trying to make a picture using processing, for mine I'm having rain moving across the screen by moving it down 5 and over 3. I'm using someone else's way of making a raidrop it is:

void drawRaindrop(int x, int y, int size) {
  fill(111, 143, 168, 65);
  noStroke();
  for (int i = 2; i < size; i++ ) {

    ellipse(x, y + i*4, i*2, i*2);
  }
}

However I'd trying to make these falls diagonally, and while I figured the way to rotate singular shapes, I have no clue how I would go about and make this raindrop look like it's actually falling in the right direction.

I'll post my entire code here and bold the parts I think are important (it's probably disgusting)

import processing.sound.*;
SoundFile file;
int totalDrops = 0;
int every5th = 0;
boolean fifth = false;


void setup() {
  size(1600, 850);
  file = new SoundFile(this, "obstacles.mp3");
  file.play();
}


void draw() {
  int[]rainX = new int[5000];  //raindrop array

  for (int i = 0; i < 300; i++) {
    int randNum = (int)(Math.random() * 1999)+1;
    rainX[i] = randNum;
  }
  int[]rainY = new int [5000];


  while (true) {

   // background(84, 116, 137); // sky (background)
  background(41, 51, 52);

    if (every5th == 5) {
      every5th = 0;
      fifth = true;
    } else {
      every5th = every5th+1;
      fifth = false;
    }


    fill(87, 59, 12);
    // rect(0, 700, 1600, 150);


    beginShape();
    vertex(0, 850);
    vertex(1600, 850);
    vertex(1600, 750);
    vertex(850, 500);
    vertex(750, 500);
    vertex(0, 750);
    endShape();



    rainX[totalDrops] = (int)(Math.random()*1600);

    if (totalDrops < 200 && fifth == true) {
      totalDrops = totalDrops+1;
    }

  **  for (int i = 0; i < totalDrops; i++) {  /


      drawRaindrop(rainX[i], rainY[i], 5);    //IRight now this just moves the raindrops at the right angle but they are just straight down raindrops that move to side, how can I can make them rotated to simulate a windy rainy day?


      rainY[i] = rainY[i] + 5;
      rainX[i] = rainX[i] + 3;

      if (rainY[i] > 1000) {
        rainY[i] = -100;
      }
    }
    redraw();
    delay(20);
  }
}**

****void drawRaindrop(int x, int y, int size) {
  fill(111, 143, 168, 65);
  noStroke();
  for (int i = 2; i < size; i++ ) {

    ellipse(x, y + i*4, i*2, i*2);
  }
}

Again sorry if this is awful never even tried asking for help or using a forum like this before so thanks in advance if you can help me.


Viewing all articles
Browse latest Browse all 2896

Trending Articles