Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DecisionDay270120
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
a.guest
DecisionDay270120
Commits
16183b4e
Commit
16183b4e
authored
Jan 21, 2020
by
a.guest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update processing.pde
parent
2d44930c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
processing.pde
processing.pde
+9
-8
No files found.
processing.pde
View file @
16183b4e
int
window_width
=
600
;
int
window_width
=
600
;
int
window_height
=
480
;
int
window_height
=
480
;
int
target_size
=
50
;
int
score
=
0
;
int
score
=
0
;
Target
aTarget
=
null
;
Target
aTarget
=
null
;
...
@@ -18,7 +17,7 @@ void input()
...
@@ -18,7 +17,7 @@ void input()
if
(
mousePressed
==
true
)
if
(
mousePressed
==
true
)
{
{
float
d
=
dist
(
mouseX
,
mouseY
,
aTarget
.
x_position
,
aTarget
.
y_position
);
float
d
=
dist
(
mouseX
,
mouseY
,
aTarget
.
x_position
,
aTarget
.
y_position
);
if
(
d
<
target_
size
)
if
(
d
<
aTarget
.
size
)
{
{
// Target hit
// Target hit
explosions
.
add
(
new
Explosion
(
aTarget
.
x_position
,
aTarget
.
y_position
));
explosions
.
add
(
new
Explosion
(
aTarget
.
x_position
,
aTarget
.
y_position
));
...
@@ -82,20 +81,22 @@ class Target {
...
@@ -82,20 +81,22 @@ class Target {
float
y_position
;
float
y_position
;
float
x_velocity
;
float
x_velocity
;
float
y_velocity
;
float
y_velocity
;
int
size
;
Target
()
Target
()
{
{
size
=
50
;
int
randomNumber
=
int
(
random
(
4
));
int
randomNumber
=
int
(
random
(
4
));
if
(
randomNumber
==
0
)
// Start on Left Hand Side
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
;
y_position
=
random
(
400
)
+
40
;
x_velocity
=
random
(
10
);
x_velocity
=
random
(
10
);
y_velocity
=
random
(
20
)
-
10
;
y_velocity
=
random
(
20
)
-
10
;
}
}
else
if
(
randomNumber
==
1
)
// Start on Right Hand Side
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
;
y_position
=
random
(
400
)
+
40
;
x_velocity
=
-
random
(
10
);
x_velocity
=
-
random
(
10
);
y_velocity
=
random
(
20
)
-
10
;
y_velocity
=
random
(
20
)
-
10
;
...
@@ -103,14 +104,14 @@ class Target {
...
@@ -103,14 +104,14 @@ class Target {
else
if
(
randomNumber
==
2
)
// Start at top of screen
else
if
(
randomNumber
==
2
)
// Start at top of screen
{
{
x_position
=
random
(
520
)
+
40
;
x_position
=
random
(
520
)
+
40
;
y_position
=
-
target_
size
;
// Starts off screen
y_position
=
-
size
;
// Starts off screen
x_velocity
=
random
(
20
)
-
10
;
x_velocity
=
random
(
20
)
-
10
;
y_velocity
=
random
(
10
);
y_velocity
=
random
(
10
);
}
}
else
// Start at bottom of screen
else
// Start at bottom of screen
{
{
x_position
=
random
(
520
)
+
40
;
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
;
x_velocity
=
random
(
20
)
-
10
;
y_velocity
=
-
random
(
10
);
y_velocity
=
-
random
(
10
);
}
}
...
@@ -122,7 +123,7 @@ class Target {
...
@@ -122,7 +123,7 @@ class Target {
y_position
+=
y_velocity
;
y_position
+=
y_velocity
;
// check to see if the target has gone off screen
// 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
;
return
false
;
}
}
...
@@ -135,7 +136,7 @@ class Target {
...
@@ -135,7 +136,7 @@ class Target {
void
render
()
void
render
()
{
{
// draws the target
// draws the target
ellipse
(
x_position
,
y_position
,
target_size
,
target_
size
);
ellipse
(
x_position
,
y_position
,
size
,
size
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment