Commit 16183b4e authored by a.guest's avatar a.guest

Update processing.pde

parent 2d44930c
int window_width=600;
int window_height=480;
int target_size = 50;
int score = 0;
Target aTarget=null;
......@@ -18,7 +17,7 @@ void input()
if (mousePressed == true)
{
float d = dist(mouseX, mouseY, aTarget.x_position, aTarget.y_position);
if (d<target_size)
if (d<aTarget.size)
{
// Target hit
explosions.add(new Explosion(aTarget.x_position, aTarget.y_position));
......@@ -82,20 +81,22 @@ class Target {
float y_position;
float x_velocity;
float y_velocity;
int size;
Target()
{
size = 50;
int randomNumber = int(random(4));
if (randomNumber == 0) // Start on Left Hand Side
{
x_position = -target_size; // Starts off screen
x_position = -size; // Starts off screen
y_position = random(400) + 40;
x_velocity = random(10);
y_velocity = random(20)-10;
}
else if (randomNumber == 1) // Start on Right Hand Side
{
x_position = 600 + target_size; // Starts off screen
x_position = 600 + size; // Starts off screen
y_position = random(400) + 40;
x_velocity = -random(10);
y_velocity = random(20)-10;
......@@ -103,14 +104,14 @@ class Target {
else if (randomNumber == 2) // Start at top of screen
{
x_position = random(520)+40;
y_position = -target_size; // Starts off screen
y_position = -size; // Starts off screen
x_velocity = random(20)-10;
y_velocity = random(10);
}
else // Start at bottom of screen
{
x_position = random(520)+40;
y_position = 480 + target_size; // Starts off screen
y_position = 480 + size; // Starts off screen
x_velocity = random(20)-10;
y_velocity = -random(10);
}
......@@ -122,7 +123,7 @@ class Target {
y_position += y_velocity;
// check to see if the target has gone off screen
if (x_position<-target_size||x_position>600+target_size||y_position<-target_size||y_position>480+target_size)
if (x_position<-size||x_position>600+size||y_position<-size||y_position>480+size)
{
return false;
}
......@@ -135,7 +136,7 @@ class Target {
void render()
{
// draws the target
ellipse(x_position,y_position,target_size,target_size);
ellipse(x_position,y_position,size,size);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment