We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, sorry if the question title is a bit off. Here is my code which basically loads 200 random images from my folder and makes them pour like the matrix code :), they all change randomly within as well. But as you can see from the loop in draw they all change at the same time according to the frameRate but I want them to change randomly in varying speeds, sometimes even stop too. I feel like this can be managed via frameCount but couldn't figure out how exactly - did some research on it as well but couldn't find any. Thank you in advance.
PImage[] myImageArray = new PImage[200];
float px;
float py;
float pz;
void setup() {
size(1920, 1080,P3D);
frameRate(15);
background(0);
for (int i = 0; i < myImageArray.length; ++i) {
(myImageArray[i] = loadImage("frag_" + i + ".jpg")).resize(0, 45);
}
}
void draw() {
background(0);
pushMatrix();
translate(px, py, pz);
py+=5; // Glitch skip
//pz-=5; // For zoom out
for (int i=-2000; i<width; i+=125) {
for (int j=-3000; j<3000; j+=95) {
//for (int j=0; j<3000; j+=25) { // For glitch effect
imageMode(CENTER);
image(myImageArray[(int)random(200)], i, j);
}
}
popMatrix();
}
Answers
Try making each of your images to have their own speed and update their position.
Thanks for the reply, I think I described what I'm aiming in a wrong way, sorry! I can make each column move downwards with different speeds but what I want is a bit different; you know when you use random() it updates it according to the frameRate, therefore here, in every frame a random image from the array is loaded but they are all changing at the same time in same speed. But I'm wondering how can I make them all change randomly in varying speeds as if each image has a different frameRate.
Do you want each column to fall at different speed keeping their distance or just different speed for each images perhaps like a rainfall?
Not exactly, I already have every row and column moving downwards at same speed and it also maintains the distance between the images (this is stated in the 2 for loops in draw, 125 and 95 in x and y) Also they are all moving downwards at same speed with py+=5. So far so good actually.
Additionally what I want to change is this; you can see in 'draw' the random function changes the images as they move, so they all change at the exact same speed according to frameRate - for example if the frameRate would be 10 all the images would change 10 times per second. But I want all of them to be changing randomly in random speeds if that makes sense :) As if each image has it's own frameRate to change randomly.
Sorry if this sounds a bit unclear, really couldn't know how to describe it in a better way..
Thanks so much.
The word "them" is your problem -- in order for there to be an addressable entity that has a separate change speed, the easiest thing is to:
See the objects and classes tutorial and examples:
Hello, thanks very much for answer. I'm trying to do this right now, somewhat the notification for this answer slipped from my eyes!!
@unknownplayer -- good luck. Follow up if you have questions.
Note that you can model rate of change in several ways -- two examples:
Each model has different properties -- for example, the first method allows you to increase or decrease the framerate, speeding up or slowing down all changes in the sketch -- 60fps will run twice as fast as 30fps. The second method is the opposite -- you can change the fps up or down, and changes will (more or less) still run at rate-independent constant speeds.