-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolypower.java
More file actions
46 lines (35 loc) · 890 Bytes
/
polypower.java
File metadata and controls
46 lines (35 loc) · 890 Bytes
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
40
41
42
43
44
45
46
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Polygon;
public class polypower extends Polygon{
/**
*
*/
private static final long serialVersionUID = 1L;
int dx, dy;
int timer, delay;
public polypower() {
dx = 7;
dy = 7;
timer = 0;
delay = 600;
int xpoints[] = {1,3,4,5,7,5,6,4,2,3};
int ypoints[] = {3,3,1,3,3,4,6,5,6,4};
for (int i = 0; i <xpoints.length; i++) {
this.addPoint(10*xpoints[i],10*ypoints[i]);
}
}
public void moveAndDraw(Graphics2D win) {
win.setColor(Color.YELLOW);
this.translate(dx, dy);
win.fillPolygon(this);
if (this.getBounds().getY() >= 730 || this.getBounds().getY() <= 0) {
dy*=-1;
}
if (this.getBounds().getX() >= 900 || this.getBounds().getX() <= 0) {
dx*=-1;
}
for (int i = 0; i <xpoints.length; i++) {
}
}
}