FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/java/examples/Basics/Arrays/ArrayObjects/Module.pde at master · Hmaal/processing · GitHub
Hmaal
processing
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
java
/
examples
/
Basics
/
Arrays
/
ArrayObjects
/
Module.pde
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (36 loc) · 830 Bytes
Breadcrumbs
processing
/
java
/
examples
/
Basics
/
Arrays
/
ArrayObjects
/
Module.pde
Copy path
File metadata and controls
39 lines (36 loc) · 830 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class
Module
{
int
xOffset;
int
yOffset;
float
x, y;
int
unit;
int
xDirection
=
1
;
int
yDirection
=
1
;
float
speed;
//
Contructor
Module
(
int
xOffsetTemp
,
int
yOffsetTemp
,
int
xTemp
,
int
yTemp
,
float
speedTemp
,
int
tempUnit
) {
xOffset
=
xOffsetTemp;
yOffset
=
yOffsetTemp;
x
=
xTemp;
y
=
yTemp;
speed
=
speedTemp;
unit
=
tempUnit;
}
//
Custom method for updating the variables
void
update
() {
x
=
x
+
(speed
*
xDirection);
if
(x
>=
unit
||
x
<=
0
) {
xDirection
*=
-
1
;
x
=
x
+
(
1
*
xDirection);
y
=
y
+
(
1
*
yDirection);
}
if
(y
>=
unit
||
y
<=
0
) {
yDirection
*=
-
1
;
y
=
y
+
(
1
*
yDirection);
}
}
//
Custom method for drawing the object
void
draw
() {
fill
(
255
);
ellipse
(xOffset
+
x, yOffset
+
y,
6
,
6
);
}
}
Back
|
FazBrowse Home
|
New Git URL