Question about If Random
in
Programming Questions
•
2 years ago
Hey there. I am currently working on a Timeshift like game. By that i mean that enemis will pop up on a random location on the screen, with a random timespan inbetween. I'm really new at Processing, i really only know the pure basics, so need help with something.
My question is why my if (r <= 5); doesn't work. What i want it to do is currently to write a sentence, just so if it works. I'm sure it's a rather easy problem, but i haven't found a answer for it, even tough i have searched quite a lot for a answer.
Any help would be appreciated.
float r;
color c = (255);
float x;
float y;
PImage Ch;
PImage Bh;
float Bx;
float By;
void setup()
{
size (800,600);
noCursor();
Ch = loadImage ("crosshairs.png");
Bh = loadImage ("BulletHole.png");
}
void draw()
{
background(c);
image (Ch, mouseX, mouseY);
float r = random(-50, 50);
loop();
}
void mousePressed()
{
color col = get(mouseX, mouseY);
if (col != c){
println("Check");
}
}
{
if (r <= 5);
println("If you see this, it works");
}
My question is why my if (r <= 5); doesn't work. What i want it to do is currently to write a sentence, just so if it works. I'm sure it's a rather easy problem, but i haven't found a answer for it, even tough i have searched quite a lot for a answer.
Any help would be appreciated.
float r;
color c = (255);
float x;
float y;
PImage Ch;
PImage Bh;
float Bx;
float By;
void setup()
{
size (800,600);
noCursor();
Ch = loadImage ("crosshairs.png");
Bh = loadImage ("BulletHole.png");
}
void draw()
{
background(c);
image (Ch, mouseX, mouseY);
float r = random(-50, 50);
loop();
}
void mousePressed()
{
color col = get(mouseX, mouseY);
if (col != c){
println("Check");
}
}
{
if (r <= 5);
println("If you see this, it works");
}
1