-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtail.java
More file actions
28 lines (26 loc) · 1.05 KB
/
Copy pathtail.java
File metadata and controls
28 lines (26 loc) · 1.05 KB
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
package snake;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
class tail extends JComponent{
// This class is simply a rectangle that is managed by the thread in the snake class
// The snake class updates each existing / visible tail's coordinates as it runs through its loop
int x, y, sisp = m.sizeOfObjects;
Rectangle2D.Float s = new Rectangle2D.Float(x,y,sisp,sisp);
tail(int inpx, int inpy){
x = inpx;
y = inpy;
setSize(m.dx,m.dy);
}
public void paintComponent(Graphics co){
Graphics2D g = (Graphics2D) co;
s.setFrame(x,y,sisp,sisp);
g.setColor(Color.WHITE);
g.fill(s);
}
void updateLoc(int inpx, int inpy){
x = inpx;
y = inpy;
repaint();
}
}