-
Notifications
You must be signed in to change notification settings - Fork 1
/
Enemy.java
151 lines (129 loc) · 2.92 KB
/
Enemy.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package data;
import static helpers.Artist.*;
import org.newdawn.slick.opengl.Texture;
import helpers.Artist;
public class Enemy {
Texture alien = QuickLoad("Fire32");
float x;
float y;
float width;
float hight;
Tile target;
Tile[] path;
public boolean isSpawned = false;
public boolean alive = true;
public int currPosition = 1;
public final float moveSpeed = 4f;
public Tile endPoint;
private int health = 4;
private int index;
private boolean gotPoints = false;
private boolean attacked = false;
public Enemy(Tile spawn, Tile endPoint, Tile[] path){
this.x = spawn.getX();
this.y = spawn.getY();
this.width = spawn.getWidth();
this.hight = spawn.getHight();
this.path = path;
this.endPoint = endPoint;
this.index = 0;
DrawQuadTex(this.alien, x, y, width, hight);
}
public void move(){
if(this.x < this.path[currPosition].getX()){
this.x = this.x + moveSpeed;
if(this.y < this.path[currPosition].getY()){
this.y = this.y + moveSpeed;
}
else if(this.y > this.path[currPosition].getY()){
this.y = this.y - moveSpeed;
}
}
else if(this.x > this.path[currPosition].getX()){
this.x = this.x - moveSpeed;
if(this.y < this.path[currPosition].getY()){
this.y = this.y + moveSpeed;
}
else if(this.y > this.path[currPosition].getY()){
this.y = this.y - moveSpeed;
}
}
else{
if(this.y < this.path[currPosition].getY()){
this.y = this.y + moveSpeed;
}
else if(this.y > this.path[currPosition].getY()){
this.y = this.y - moveSpeed;
}else{
currPosition++;
}
}
}
public void DrawEnemy(){
DrawQuadTex(this.alien, x, y, width, hight);
}
public Tile GetTarget(){
return this.target;
}
public void SetTarget(Tile target){
this.target = target;
}
public void setX(int x){
this.x = x;
}
public void setY(int y){
this.y = y;
}
public float getX(){
return this.x;
}
public float getY(){
return this.y;
}
public int getCurrPosition(){
return currPosition;
}
public boolean isAlive(){
return alive;
}
public void die(){
this.alive = false;
}
public float getWidth() {
return width;
}
public void setWidth(float width) {
this.width = width;
}
public float getHight() {
return hight;
}
public void setHight(float hight) {
this.hight = hight;
}
public void setHealth(int dmg){
this.health -= dmg;
}
public int getHealth(){
return this.health;
}
public void setIndex(int index){
this.index = index;
}
public int getIndex(){
return this.index;
}
public void gotPoints(){
this.gotPoints = true;
}
public boolean getGotPoints(){
return this.gotPoints;
}
public int attackBase(){
this.attacked = true;
return 1;
}
public boolean getAttacked(){
return this.attacked;
}
}