Hi everyone, I’ve been struggling with my art project due to my lack of experience and knowledge of Processing. My problem concerns coding, which then lead to a project guidance problem. I will try my best to explain clearly my project, the problems I am facing and the results I have so far. Here is the link to a drive where I added visual explanations, along with all the data files if necessary :
The project
The idea, is to show a randomly selected portrait, then out of three possible events (Call or Email or Kill) randomly select one of them and show its text, finally show a new randomly selected portrait, and repeat. An example is illustrated in the drive (fig.1). One of the possible event being “Kill”, the program should run until everyone dies.
The rules that I am trying to apply are :
- The “CALLS” event CAN link to person that appeared before the “CALLS” image (a person can call herself)
- The “CALLS” event CAN link the same duo of persons multiple times
- The two rules above also applies to the “EMAILS” event
- The “KILLS” event CAN link to person that appeared before the “KILLS” image (a person can kill herself)
- Once a person appears AFTER the “KILLS” event, the person CANNOT appear ever again to the screen (if a person is killed, it must disappear from the randomly selected persons)
For the moment I’ve decided to work on different sketches for the different parts of the code, it’s easier to me.
This is the sketch that shows a random image picked from a library of 155 portraits. The code works.
PImage portrait;
int rand;
void setup() {
size(640, 640);
rand = int(random(1, 155));
takerandomimage(“portrait” + nf(rand, 3) + “.jpg”);
}
void takerandomimage(String fn) {
portrait = loadImage(fn);
image(portrait, 0, 0);
}
This is the sketch that treats the “event” part. Based on a random number, one out of the three events is chosen. The first one represents the action of calling, the second one represents the action of sending a mail, the last one represents the action of killing. The code works, appart from the sound, I don’t hear anything.
import processing.sound.*;
SoundFile Son;
int rand;
int event;
void setup() {
size(640, 640);
event = int (random (1, 4));
if (event == 1) {
PImage telephone;
telephone = loadImage(“Calls.jpg”);
image (telephone, 0, 0);
Son = new SoundFile(this, “Son_calls.mp3”);
Son.play();
} else if (event == 2) {
PImage mail;
mail = loadImage(“Emails.jpg”);
image (mail, 0, 0);
Son = new SoundFile(this, “Son_emails.mp3”);
Son.play();
} else if (event == 3) {
PImage arme;
arme = loadImage(“Kills.jpg”);
image (arme, 0, 0);
Son = new SoundFile(this, “Son_kills.mp3”);
Son.play();
}
}
With this two codes working, I am trying to put them together, but the main problem that I am facing is: how can I prevent the dead persons from showing up again ?
I found this sketch that generates random numbers without repetitions.
void setup() {
size(640, 640);
final int NUM = 155;
final IntList nums = new IntList(NUM);
for (int i = 0; i != NUM; nums.append(++i));
nums.shuffle();
println(nums);
final int[] arr = nums.array();
println();
println(arr);
exit();
}
I was thinking that I could implement the variable [0] inside the loadImage “name”+".jpg", followed by a command to add 1 to his value. This way I would have list of random numbers that won’t repeat, from which I could pick from [0] to [154].
The structure would be like shown in (fig.2).
The problem is that a dead person could appear when going through the first random portait selection node (the top one). i.e. after going through a “CALLS” or “EMAILS” event.
A solution could be to communicate a “blacklist” of the dead persons to the first random portrait selection node, but I don’t even know if it’s possible to do so. I think I am thinking about the structure in a wrong way, but my lack of knowledge doesn’t allow me to find an alternative. I have tried to find sketches that could help me but I can’t find the appropriate command that would suit my project.
I am aware that this a lot to ask for, and that my request is quite complex, but honestly anything would help. Thank you and have a nice day