-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.java
62 lines (51 loc) · 1.07 KB
/
Node.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.awt.*;
public class Node
{
// how big the node should render as (radius)
final int RENDER_SIZE = 8;
// whether the node has physics applied or not
public boolean fixed;
// the position of the node
public double x;
public double y;
// the position of the node last tick
public double oldX;
public double oldY;
// initialize a new node
public Node(int x, int y)
{
this.x = x;
this.y = y;
this.oldX = x;
this.oldY = y;
}
// draw the node on the screen
public void draw(Graphics g)
{
if(fixed)
g.setColor(Color.BLUE);
else
g.setColor(Color.BLACK);
g.fillOval(getIntX() - RENDER_SIZE / 2, getIntY() - RENDER_SIZE / 2, RENDER_SIZE, RENDER_SIZE);
}
// get a rounded version of the x
public int getIntX()
{
return (int)Math.round(x);
}
// get a rounded version of the y
public int getIntY()
{
return (int)Math.round(y);
}
// get a rounded version of the oldX
public int getIntOldX()
{
return (int)Math.round(oldX);
}
// get a rounded version of the oldY
public int getIntOldY()
{
return (int)Math.round(oldY);
}
}