The image file just flashes by
in
Programming Questions
•
2 years ago
Hi everybody. I'm currently trying to code a very basic Time Crisis typ game, the type of game where enemies pop up and you have to shoot them, or in this case click them. The code is working fine for me at the moment, after a bit of help from this forum earlier today. Thanks to my "if random" code enemies spawn is i like them to do, the only problem is that they stay there for a fraction of a second. I'm very new to processing, so i have no idea what the problem is and i've found nothing searching around. Any help would be appreciated.
My code is as follows.
float r;
float rx;
float ry;
color c = (255);
float x;
float y;
PImage Ch;
PImage Bh;
float Bx;
float By;
PImage Enemy;
int Score;
PFont font;
void setup()
{
size (800,600);
noCursor();
Ch = loadImage ("crosshairs.png");
Bh = loadImage ("BulletHole.png");
Enemy = loadImage ("Awesome Smiley.png");
Score = 0;
}
void draw()
{
background(c);
image (Ch, mouseX, mouseY);
float r = random(0, 100);
float rx = random (0, 800);
float ry = random (0, 600);
loop();
{
if (r <=2)
image(Enemy,rx,ry);
}
}
void mousePressed()
{
color col = get(mouseX, mouseY);
if (col == c){
Score = Score + 50;
println(Score);
}
}
My code is as follows.
float r;
float rx;
float ry;
color c = (255);
float x;
float y;
PImage Ch;
PImage Bh;
float Bx;
float By;
PImage Enemy;
int Score;
PFont font;
void setup()
{
size (800,600);
noCursor();
Ch = loadImage ("crosshairs.png");
Bh = loadImage ("BulletHole.png");
Enemy = loadImage ("Awesome Smiley.png");
Score = 0;
}
void draw()
{
background(c);
image (Ch, mouseX, mouseY);
float r = random(0, 100);
float rx = random (0, 800);
float ry = random (0, 600);
loop();
{
if (r <=2)
image(Enemy,rx,ry);
}
}
void mousePressed()
{
color col = get(mouseX, mouseY);
if (col == c){
Score = Score + 50;
println(Score);
}
}
1