-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
85 lines (66 loc) · 1.66 KB
/
Node.java
File metadata and controls
85 lines (66 loc) · 1.66 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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.game1;
import com.badlogic.gdx.math.Intersector;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector3;
public class Node {
int x;
int y;
int index;
static int nextindex = 1;
Vector3 pos = new Vector3();
Rectangle body;
Node right;
Node left;
Node up;
Node down;
GameScreen gamescreen;
public Node(int x, int y, GameScreen gamescreen) {
pos.x = x;
pos.y = y;
pos.z = 0;
//gamescreen.camera.unproject(pos);
this.x = x;
this.y = y;
this.gamescreen = gamescreen;
this.index = nextindex;
increment();
body = new Rectangle(x - 16, y - 16 ,32,32);
for(Node node : gamescreen.allnodes) {
if(node.x == this.x - 32 && node.y == this.y) {
this.left = node;
}
if(node.x - 32 == this.x && node.y == this.y) {
this.right = node;
}
if(node.x == this.x && node.y == this.y - 32) {
this.down = node;
}
if(node.x == this.x && node.y - 32 == this.y) {
this.up = node;
}
}
/*for(Node node : gamescreen.allnodes) {
if(Intersector.overlaps(node.body, new Rectangle(this.x - 32, this.y, 100,100))) {
this.right = node;
}*/
}
public void increment() {
nextindex ++;
}
public void makeNabour() {
for(Node node : gamescreen.allnodes) {
if(node.x == this.x - 32 && node.y == this.y) {
this.left = node;
}
if(node.x - 32 == this.x && node.y == this.y) {
this.right = node;
}
if(node.x == this.x && node.y == this.y - 32) {
this.down = node;
}
if(node.x == this.x && node.y - 32 == this.y) {
this.up = node;
}
}
}
}