-
Notifications
You must be signed in to change notification settings - Fork 1
/
Eck.java
60 lines (48 loc) · 1.17 KB
/
Eck.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
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.File;
import java.awt.event.*;
import java.io.IOException;
public class Eck{
public int eckX, eckY, health, damage;
public int ew, eh;
BufferedImage EckImage;
public Eck(){
eckX = 450;
eckY = 350;
damage = 10;
health = 1000;
try{
File eckImg = new File("Eck.png");
EckImage = ImageIO.read(eckImg);
ew = EckImage.getWidth(null);
eh = EckImage.getHeight(null);
}
catch(IOException e){
System.exit(1);
}
}
public int getX(){
return eckX;
}
public int getY(){
return eckY;
}
public int getDmg(){
return damage;
}
public int getHealth(){
return health;
}
public void move(int moveX, int moveY){
eckX += moveX;
eckY += moveY;
}
public void draw(Graphics g){
g.drawImage(EckImage, eckX, eckY, eckX+ew, eckY+eh, 0, 0, ew, eh, null);
g.setColor(Color.BLUE);
g.fillRect(eckX - 5, eckY - 5, health/10, 5);
}
}