-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerShip.java
More file actions
60 lines (50 loc) · 1.5 KB
/
PlayerShip.java
File metadata and controls
60 lines (50 loc) · 1.5 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
51
52
53
54
55
56
57
58
59
60
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
public class PlayerShip extends Ship {
boolean playerIsAccel;
public int spriteWidth;
public int spriteHeight;
public BufferedImage sprite;
protected PlayerShip() {}
public PlayerShip(int X, int Y, int sID) {
// Pass maxVelocity to SpaceObj.
super(5);
turnRate = Math.PI / 160;
baseAccelRate = .2;
mass = 4;
maxStructInteg = 150;
structInteg = maxStructInteg;
// Hilarious.
//int numGuns = 300;
//int numGuns = 1;
Weapon w = BulletGun.newDefaultWeapon(this);
// Hilarious.
//w.setVelocity(w.getVelocity() * 2);
//w.setTTL(w.getTTL() * 10);
//w.setReloadTime(w.getReloadTime() / numGuns);
weapons.add(w);
shipID = sID;
angle = .5*Math.PI;
x = X;
y = Y;
dx = 0;
dy = 0;
playerIsAccel = false;
spriteWidth = 100;
spriteHeight = 100;
origObjImg = null;
try {
origObjImg =
ImageIO.read(getClass().getResource("playership.png"));
} catch (IOException e) {
e.printStackTrace();
}
diam = 50;
updateSprite();
}
public void updateSprite() {
int spriteIndex = ((int)(24.0 * (angle + Math.PI) / (2.0 * Math.PI)) + 6) % 24;
sprite = origObjImg.getSubimage(spriteIndex * spriteWidth, 0, spriteWidth, spriteHeight);
}
}