-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.java
More file actions
49 lines (39 loc) · 1.21 KB
/
Enemy.java
File metadata and controls
49 lines (39 loc) · 1.21 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
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;
import javax.imageio.ImageIO;
public class Enemy extends GameObject {
Image pepe;
public Enemy(double speed, double direction, int size, double health,int x, int y) {
super(speed, direction, size, health, x, y, null);
try {
URL url = getClass().getResource("images/pepe.png");
pepe = ImageIO.read(url);
} catch (Exception e) {
System.out.println("problem opening the pepe");
e.printStackTrace();
}
// TODO Auto-generated constructor stub
}
@Override
public void draw(Graphics g) {
// this.setBoundingRect((int)this.getX(), (int)this.getY(), 20, 20);
g.drawImage(pepe, this.getX(), this.getY(), getSize(), getSize(), null);
g.drawRect(this.getX(), this.getY(), this.getBoundingRect().width, this.getBoundingRect().height);
}
public void turn(){
if(getDirection() == 0)
setDirection(Math.PI);
else if (getDirection() == Math.PI)
setDirection(0);
}
public GameObject shoot(){
Dew b = new Dew(getSpeed()*1.5, Math.PI, getSize()/30, 1000, this.getX(), this.getY(), Color.red, "pepe");
return b;
}
@Override
public void checkOffScreen() {
// TODO Auto-generated method stub
}
}