-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.java
More file actions
58 lines (47 loc) · 1.18 KB
/
Enemy.java
File metadata and controls
58 lines (47 loc) · 1.18 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Enemy implements IGameConstants{
private int x;
private int y;
private int w;
private int h;
private Image image;
private int speed;
public int points;
public boolean isVisible = true;
public Enemy(int x, int y, int points, int dir){
this.points = points;
this.x = x;
this.y = y;
this.h = ENEMY_H;
this.w = ENEMY_W;
image = new ImageIcon(Enemy.class.getResource(ENEMY_IMG)).getImage();
this.speed = this.speed * dir;
}
public void drawEnemy(Graphics graphics){
if (isVisible == true) {
graphics.drawImage(image, x, y, w, h, null);
}
}
public void changeDirection(int dir, int speed){
this.speed = speed;
this.speed = this.speed * dir;
}
public void move(){
x += speed;
}
public int getX() {
return x;
}
public void setY(int y) {
this.y = y;
}
public int getY() {
return y;
}
public void setSpeed(int speed) {
this.speed = speed;
}
}