-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStone.java
More file actions
50 lines (40 loc) · 1.16 KB
/
Stone.java
File metadata and controls
50 lines (40 loc) · 1.16 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
package SaueSpillet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
public class Stone extends GameObject {
private int width = 48;
private int height = 31;
private double gravity = 0.2;
private Image stonePic;
public Stone(float x, float y, ID id, Handler handler, float velX, int hit) {
super(x, y, id, handler, hit);
this.velX = velX;
loadpic();
this.velY = (float) (-velX*1.4);
}
public Rectangle getBounds() {
return new Rectangle((int) x, (int) y, width, height);
}
public void loadpic() {
stonePic = new ImageIcon(
"C:\\Users\\Sjur\\tdt4100-2018-master\\git\\tdt4100-2018\\minegenkode\\GamepackRes\\stone.png")
.getImage();
}
public void tick() {
velY += gravity;
x += velX;
y += velY;
if (this.hit > Hud.getEnemysPerStone()) {
handler.removeObject(this);
}
if (y >= Game.HEIGHT - 58 || x >= Game.WIDTH)
handler.object.remove(this);
handler.addObject(new Trail((int) x, (int) y, ID.Trail, handler, width, height, 0.11, Color.LIGHT_GRAY, 1f));
}
public void render(Graphics g) {
g.drawImage(stonePic, (int) x, (int) y, null);
}
}