-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAlien.java
More file actions
35 lines (28 loc) · 904 Bytes
/
Alien.java
File metadata and controls
35 lines (28 loc) · 904 Bytes
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
import java.awt.*;
// Thoughts on making this astract/an
// interface to build more detailed aliens???
abstract class Alien extends GameEntity{
// Declare here for switch/better practice
Graphics2D graphics;
double fric = 0.7;
int scaleWidth = 2;
int scaleHeight = 2;
int barx = 10;
int bary = 10;
public abstract void set();
public abstract String getImg();
public Alien(int x,int y) {
super(x,y);
set();
setImage();
bounds.setSize(scaleWidth*getWidth(),scaleHeight*getHeight());
}
// Abstract draw. But if we do keep one class. Easier to manage with switch
public void draw(Graphics2D g) {
g.drawImage(img,getX(),getY(),scaleWidth*getWidth(),scaleHeight*getHeight(),null);
graphics = (Graphics2D)g.create();
graphics.setColor(Color.red);
graphics.fill3DRect(getX()+this.barx,getY()-this.bary,this.health,10,true);
graphics.dispose();
}
}