The video appears to be playing as I am getting the sound when I run the sketch but no picture, I thought it might be the background but changing it with a trial and error approach has no effect. Any ideas?
I have two sketches that I am trying to combine. I was trying to treat each sketch as a separate function but I am running into problems due to one of the sketches being one that simply plays a video. (Sound no picture etc.) The aim is for the video to play once and then move onto the rain straight after, although it seems latency is unavoidable.
My attempts have all been a mess so I will upload the sketches separately in hopes someone may have a suggestion!
Hi I am having an issue with a rain generator, it worked fine until I added extra function to change the number of drops periodically. Now the speed parameters stipulated in the class Drop not being applied.
Hope someone can help me!
Thanks,
Katie
int savedTime;
int totalTime = 60000;
int passedTime;
int num_drops1 = 4;
int num_drops2 = 16;
int num_drops3 = 32;
int num_drops4 = 64;
int num_drops5 = 128;
int num_drops6 = 246;
int num_drops7 = 400;
void setup()
{
size(500, 500);
smooth();
noStroke();
savedTime = millis();
}
void draw() {
background(0);
passedTime = millis() - savedTime;
if (passedTime <= 7500) {
rain1();
}
else if ((passedTime <= 15000) && (passedTime > 7500)) {
rain2();
}
else if ((passedTime <= 22500) && (passedTime > 15000)) {
rain3();
}
else if ((passedTime <= 30000) && (passedTime > 22500)) {
rain4();
}
else if ((passedTime <= 37500) && (passedTime > 30000)) {
rain5();
}
else if ((passedTime <= 45000) && (passedTime > 37500)) {
rain6();
}
else if ((passedTime <= 60000) && (passedTime > 45000)) {
rain1();
}
else {
stop();
savedTime = millis(); // Save the current time to restart the timer!
}
println (passedTime + " ") ;
}
////////////////////////////////// RAIN FUNCTION //////////////////////////////////
void rain1() {
Drop[] myDrops = new Drop[num_drops1];
for (int i = 0; i<num_drops1; i++)
{
myDrops[i] = new Drop();
myDrops[i].posX = random(0, width);
myDrops[i].posY = random(0, height);
myDrops[i].speedX = random(0, 3);
}
if (passedTime < totalTime) {
for (int i = 0; i<num_drops1; i++)
{
myDrops[i].update();
}
}
}
void rain2() {
Drop[] myDrops = new Drop[num_drops2];
for (int i = 0; i<num_drops2; i++)
{
myDrops[i] = new Drop();
myDrops[i].posX = random(0, width);
myDrops[i].posY = random(0, height);
myDrops[i].speedX = random(0, 3);
}
if (passedTime < totalTime) {
for (int i = 0; i<num_drops2; i++)
{
myDrops[i].update();
}
}
}
void rain3() {
Drop[] myDrops = new Drop[num_drops3];
for (int i = 0; i<num_drops3; i++)
{
myDrops[i] = new Drop();
myDrops[i].posX = random(0, width);
myDrops[i].posY = random(0, height);
myDrops[i].speedX = random(0, 3);
}
if (passedTime < totalTime) {
for (int i = 0; i<num_drops3; i++)
{
myDrops[i].update();
}
}
}
void rain4() {
Drop[] myDrops = new Drop[num_drops4];
for (int i = 0; i<num_drops4; i++)
{
myDrops[i] = new Drop();
myDrops[i].posX = random(0, width);
myDrops[i].posY = random(0, height);
myDrops[i].speedX = random(0, 3);
}
if (passedTime < totalTime) {
for (int i = 0; i<num_drops4; i++)
{
myDrops[i].update();
}
}
}
void rain5() {
Drop[] myDrops = new Drop[num_drops5];
for (int i = 0; i<num_drops5; i++)
{
myDrops[i] = new Drop();
myDrops[i].posX = random(0, width);
myDrops[i].posY = random(0, height);
myDrops[i].speedX = random(0, 3);
}
if (passedTime < totalTime) {
for (int i = 0; i<num_drops5; i++)
{
myDrops[i].update();
}
}
}
void rain6() {
Drop[] myDrops = new Drop[num_drops6];
for (int i = 0; i<num_drops6; i++)
{
myDrops[i] = new Drop();
myDrops[i].posX = random(0, width);
myDrops[i].posY = random(0, height);
myDrops[i].speedX = random(0, 3);
}
if (passedTime < totalTime) {
for (int i = 0; i<num_drops6; i++)
{
myDrops[i].update();
}
}
}
void rain7() {
Drop[] myDrops = new Drop[num_drops7];
for (int i = 0; i<num_drops7; i++)
{
myDrops[i] = new Drop();
myDrops[i].posX = random(0, width);
myDrops[i].posY = random(0, height);
myDrops[i].speedX = random(0, 3);
}
if (passedTime < totalTime) {
for (int i = 0; i<num_drops7; i++)
{
myDrops[i].update();
}
}
}
////////////////////////////////// RAIN CLASS ///////////////////////////////////////
class Drop
{
//properties
int myDiameter = 4;
float posX = 250;
float posY = 250;
float speedX = 0.1;
float speedY = 0;
float gravity = 0.05;
//method
void update()
{
//ellipse(posX, posY, myDiameter, myDiameter);
fill(#62B7FF, 200);
ellipse(posY, posX, myDiameter, myDiameter);
posX += speedX + 0.01;
speedX = speedX + gravity;
if (posX > width)
{
posX = 0;
speedX = speedX*-.10;
}
}
}
////////////////////////////////// END RAIN CLASS ///////////////////////////////////
Hey, I have been working on some code with moving rectangles and I need to set time constraints for each method but as I am new to processing I can't figure it out! Maybe it is not possible to add this to my code? Each method needs to be carried out within a certain time frame. Can anyone help?