-
Notifications
You must be signed in to change notification settings - Fork 1
/
Meteor.java
41 lines (33 loc) · 858 Bytes
/
Meteor.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
import java.awt.*;
import java.awt.Image;
import javax.swing.ImageIcon;
/**
* Subclass of GameObject for laser properties
*/
public class Meteor extends GameObject{
Image enemy;
public Meteor(int x, int y, ID id) {
super(x, y, id);
velY = 2;//velocity is positive so it moves down
}
public void update() {
x += velX;
y += velY;
x = Game.clamp(x, 0, Game.WIDTH-24);//y is zero to spawn at top of canvas
}
/**
* Draws 64x64 Meteor.png on top of the hitbox
* @param Graphics g
*/
public void draw(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Image img1 = Toolkit.getDefaultToolkit().getImage("64Meteor.png");
g.drawImage(img1, x, y, null);
}
/**
* Draws 48x48 for hitbox of Meteor
*/
public Rectangle getBounds() {
return new Rectangle(x, y, 48, 48);
}
}