java - Image not displaying with random -


i coding flappy bird clone inside processing(java). whenever code down below executes nothing shows on screen.

void display() {   float birdpick = random(0, 1);    if (birdpick == 0)   {     image(yellowbird, x, y, 80, 80);   }    if (birdpick == 1)   {     image(bluebird, x, y, 80, 80);   } } 

calling random(0, 1) returns float between 0 , 1.

in other words, these numbers things .01 or .333. never 0, , never 1 (the second number not included).

if want if statement evaluate true 50% of time, can check if value less .5, since half values below , half values above that.

 float birdpick = random(0, 1);  if (birdpick < .5){    image(yellowbird, x, y, 80, 80);  }  else{    image(bluebird, x, y, 80, 80);  } 

more info can found in the reference


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -