I can't made my project, please some help?

Hello everyone,

I’m sorry if i make some errors in my english, i’m french and studying english now, so sorry !
i came here because I have 2 questions.
I’m in a computer graphist school, one of my class is “Programmation” so for my final evaluation this year and because covid-19, we must made a project when we never had lessons …
after many search on web, youtube, processing forum and official processing help, i managed to do some of my work but 2 part it’s impossible without help I think… so i came here.

the project is to create on processing a still image (it’s done) an animation (I chose falling snow and I succeeded with the parameters that I wanted), integrate an image on the project (it’s done) and the two that cause problems are:

  • create a draw of 4 images which according to the draw on 10, one will appear. if i don’t make myself clear i will do my best to explain.

  • the other is to integrate a background that changes depending on the time, for example, from 7 a.m. to 12 p.m. the sky is light blue, from 12:01 until 5:59 p.m. it will be slightly orange.

Can you give me tips, techniques, help to overcome my difficulties?
thank you very much for the help that will help me or not.

Have a nice day everyone.

Do you mean choose 4 from a list of 10 images randomly?

2 Likes

I am thinking this may mean each of the four images appears one at a time at some interval of 10? Like every 10 frames or every 10 seconds? @pyxdesign please clarify. :slight_smile:

:nerd_face:

2 Likes

Oh yeah excuse me, it’s not clear…
I think giving my teacher’s instructions will be easier :

. A set of 4 different external images (transparent pngs) still
(they will not be animated) which will fit harmoniously into the
drawing (rather in the background).

These images must imperatively be in the number
of 4 and will be drawn by lot by the sketch with the
following probabilities:

:black_small_square: 1 in 10 chance of finding the first image
:black_small_square: 1 in 10 chance of finding the second image
:black_small_square: 3 out of 10 chances of finding the third image
:black_small_square: 5 out of 10 chances of finding the fourth image
◦ These images will be placed randomly in a square
thanks to a function which takes as parameters:

:black_small_square: the position of the center of the square,
:black_small_square: the dimension (= width = height) of the square
:black_small_square: the number of copies of images (one of the 4) to
draw
2. The backdrop will vary depending on what time it is:
◦ at night (between 9:30 p.m. inclusive and 6 a.m. excluded).
◦ In the afternoon (between 12:00 p.m. inclusive and 5:59 p.m. inclusive)
◦ In the evening (between 6 p.m. inclusive and 9:29 p.m. inclusive)
◦ In the morning (between 6:00 a.m. inclusive and 11:59 a.m. inclusive)

Thank you for your quick reponses ! :slight_smile:

Ah. Ok, got it.

For your first question, since it is about probability, this Coding Train on youTube gives an excellent introduction on how to break this down:

And for your second question, this earlier forum thread may be of help:

:nerd_face:

2 Likes

Isn’t using hour() and minute() better for the second question?
https://processing.org/reference/hour_.html
https://processing.org/reference/minute_.html

2 Likes

Yes, I suppose it is. :slightly_smiling_face: I was mainly directing to this thread for the startTime, passedTime and trigger the event information as outlined by @Chrisir.

:nerd_face:

1 Like

I found in the website of my teacher, a game with a code like the second question, but i don’t understand how it work:

it’s:

// créer le fond du matin :
leFondDuMatin = new Fond(color(119, 200, 240)); // couleur de ciel bleu clair
leFondDuMatin.setTheGround(loadImage(“sol.png”), 0, 150, width, height-150); // avec le sol

// créer le fond de l’après-midi :
leFondDePM = new Fond(color(70, 122, 203)); // couleur de ciel bleu foncé
leFondDePM.setTheRainbow(width/2, 250, 600, 600, rainbowWidth, 100); // + arc en ciel clair
leFondDePM.setTheGround(loadImage(“sol.png”), 0, 150, width, height-150); // avec le sol

// créer le fond du soir :
leFondDuSoir = new Fond(color(255, 140, 0)); // couleur de ciel orangé
leFondDuSoir.setTheRainbow(width/2, 250, 600, 600, rainbowWidth, 50); // + arc en ciel terne
leFondDuSoir.setTheGround(loadImage(“sol.png”), 0, 150, width, height-150); // avec le sol

// créer le fond de la nuit :
leFondDeNuit = new Fond(color(0, 0, 70)); // couleur de ciel bleu nuit
leFondDeNuit.setTheStars(0, 0, 500, 250, 30); // + étoiles
leFondDeNuit.setTheGround(loadImage(“sol.png”), 0, 150, width, height-150); // avec le sol

void draw() {
// le ciel dépend de l’heure qu’il est !
int h = hour();
int m = minute();
Fond leBonFond = leFondDuMatin; // le fond selon l’heure qu’il est
// (matin par défaut)

if (h>=22 && h<=23 ||
h>=0 && h<=5 ||
h==6 && m<30) { // nuit entre 22h00 et 6h29
leBonFond = leFondDeNuit; // fond de nuit !
} else if (h>=12 && h<=17) { // PM entre 12h00 et 17h59
leBonFond = leFondDePM; // fond de l’après-midi !
} else if (h>=18 && h<=21) { // soir entre 18h00 et 21h59
leBonFond = leFondDuSoir; // fond du soir !
}

// dessiner le fond :
leBonFond.affiche();

I test to copy this in my code but it don’t work but processing accept the code. any idea ?

The code is incomplete

There is a class Fond missing

variable rainbowWidth is missing

This would be the code

(still need the class Fond)

Fond leFondDuMatin, leFondDePM, leFondDuSoir, leFondDeNuit; 
float rainbowWidth = 450; 

//--------------------------------------------------------

void setup() {

  size(700, 700); 

  // créer le fond du matin :
  leFondDuMatin = new Fond(color(119, 200, 240)); // couleur de ciel bleu clair
  leFondDuMatin.setTheGround(loadImage("sol.png"), 0, 150, width, height-150); // avec le sol

  // créer le fond de l’après-midi :
  leFondDePM = new Fond(color(70, 122, 203)); // couleur de ciel bleu foncé
  leFondDePM.setTheRainbow(width/2, 250, 600, 600, rainbowWidth, 100); // + arc en ciel clair
  leFondDePM.setTheGround(loadImage("sol.png"), 0, 150, width, height-150); // avec le sol

  // créer le fond du soir :
  leFondDuSoir = new Fond(color(255, 140, 0)); // couleur de ciel orangé
  leFondDuSoir.setTheRainbow(width/2, 250, 600, 600, rainbowWidth, 50); // + arc en ciel terne
  leFondDuSoir.setTheGround(loadImage("sol.png"), 0, 150, width, height-150); // avec le sol

  // créer le fond de la nuit :
  leFondDeNuit = new Fond(color(0, 0, 70)); // couleur de ciel bleu nuit
  leFondDeNuit.setTheStars(0, 0, 500, 250, 30); // + étoiles
  leFondDeNuit.setTheGround(loadImage("sol.png"), 0, 150, width, height-150); // avec le sol
}

void draw() {
  // le ciel dépend de l’heure qu’il est !
  int h = hour();
  int m = minute();
  Fond leBonFond = leFondDuMatin; // le fond selon l’heure qu’il est
  // (matin par défaut)

  if (h>=22 && h<=23 ||
    h>=0 && h<=5 ||
    h==6 && m<30) { 
    // nuit entre 22h00 et 6h29
    leBonFond = leFondDeNuit; // fond de nuit !
  } else if (h>=12 && h<=17) {
    // PM entre 12h00 et 17h59
    leBonFond = leFondDePM; // fond de l’après-midi !
  } else if (h>=18 && h<=21) { 
    // soir entre 18h00 et 21h59
    leBonFond = leFondDuSoir; // fond du soir !
  }

  // dessiner le fond :
  leBonFond.affiche();
}
//