I need help, with a shooting gallery type game. Targets are going to pop up at random at a random location and you have to click them to score. What i currently need help with is the Random locations and the Hit detection. So far the enemy (smiley) just sits in the left corner of the program, and does nothing. I haven't got any hit detection at all, simply because i'm not to sure how to do it.
Here's my code so far:
float r;
float rx;
float ry;
float x;
float y;
float px;
float py;
PImage Ch;
PImage Bh;
float Bx;
float By;
float distance;
PImage Enemy;
int Score;
boolean bDisplay;
boolean bDisplay2;
boolean bDisplay3;
boolean bDisplay4;
boolean bDisplay5;
boolean bDisplay6;
boolean bDisplay7;
boolean bDisplay8;
boolean bDisplay9;
boolean bDisplay10;
color c =(255);
color col;
int enemyRadie = 50;
int i;
Smiley[] smiler = new Smiley[10];
PFont f;
float m;
class Smiley {
int x;
int y;
boolean visible;
PImage picture;
I'm trying to create a Shooting Game, where Smiley's will pop up and you have to shoot them, by clicking on them. So far i have quite alot of code, but the problem lies in the lines that says:
float dx = mouseX - smileys[i].position.x;
float dy = mouseY - smileys[i].position.y;
float distance = sqrt( dx*dx + dy*dy );
For some reason that i don't know, (i'm very new to processing, so it might be very simple), the program says that Position cannot be resolved or is not a field. What that code is, is basically a hit detection code, any help would help.
My code:
float r;
float rx;
float ry;
float x;
float y;
float dx;
float dy;
PImage Ch;
PImage Bh;
float Bx;
float By;
PImage Enemy;
int Score;
boolean bDisplay;
boolean bDisplay2;
boolean bDisplay3;
boolean bDisplay4;
boolean bDisplay5;
boolean bDisplay6;
boolean bDisplay7;
boolean bDisplay8;
boolean bDisplay9;
boolean bDisplay10;
color c =(255);
color col;
int enemyRadie = 50;
int i;
float smiley;
Hey there. I am currently programming a very simple shooting game, in which Smiley's will pop up at random, and you have to click them to get 50 points. I have most of the code done, and i currently only have the shooting part left. What i want it to do is to basically recognize when you click them. I have tried using a color comparing thing, where i used the "Get" command, but i didn't get it work. This is the code at the moment. Please note that i am very new to processing, so any advice for my code would be appreciated.
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;
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");
}