Last change
on this file was 7d9c033, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago |
Initial commit, code decompiled from a jar
|
-
Property mode
set to
100644
|
File size:
1.9 KB
|
Line | |
---|
1 | import java.awt.image.ImageObserver;
|
---|
2 | import java.awt.Image;
|
---|
3 | import java.awt.Graphics;
|
---|
4 | import java.awt.image.BufferedImage;
|
---|
5 |
|
---|
6 | public class Shot {
|
---|
7 | private int x;
|
---|
8 | private int y;
|
---|
9 | private int speed;
|
---|
10 | private int angle;
|
---|
11 | private int damage;
|
---|
12 | private BufferedImage pic;
|
---|
13 | private long timeFired;
|
---|
14 | private int xFired;
|
---|
15 | private int yFired;
|
---|
16 |
|
---|
17 | public Shot() {
|
---|
18 | this.x = 0;
|
---|
19 | this.y = 0;
|
---|
20 | this.speed = 0;
|
---|
21 | this.damage = 0;
|
---|
22 | this.pic = null;
|
---|
23 | this.timeFired = System.currentTimeMillis();
|
---|
24 | this.xFired = 0;
|
---|
25 | this.yFired = 0;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public Shot(final int newX, final int newY, final int newDamage, final int newSpeed, final BufferedImage newPic) {
|
---|
29 | this.x = newX;
|
---|
30 | this.y = newY;
|
---|
31 | this.speed = newSpeed;
|
---|
32 | this.damage = newDamage;
|
---|
33 | this.pic = newPic;
|
---|
34 | this.timeFired = System.currentTimeMillis();
|
---|
35 | this.xFired = newX;
|
---|
36 | this.yFired = newY;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void draw(final Graphics g) {
|
---|
40 | this.y = (int)(this.yFired + (System.currentTimeMillis() - this.timeFired) * this.speed / 1000L);
|
---|
41 | g.drawImage(this.pic, this.x - this.pic.getWidth() / 2, this.y - this.pic.getHeight() / 2, null);
|
---|
42 | }
|
---|
43 |
|
---|
44 | public boolean outOfBounds() {
|
---|
45 | return this.y + this.pic.getHeight() / 2 < 0 || this.y - this.pic.getHeight() / 2 > 600 || (this.x + this.pic.getWidth() / 2 < 0 || this.x - this.pic.getWidth() / 2 > 800);
|
---|
46 | }
|
---|
47 |
|
---|
48 | public int getX() {
|
---|
49 | return this.x;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public int getY() {
|
---|
53 | return this.y;
|
---|
54 | }
|
---|
55 |
|
---|
56 | public int getSpeed() {
|
---|
57 | return this.speed;
|
---|
58 | }
|
---|
59 |
|
---|
60 | public int getDamage() {
|
---|
61 | return this.damage;
|
---|
62 | }
|
---|
63 |
|
---|
64 | public BufferedImage getPic() {
|
---|
65 | return this.pic;
|
---|
66 | }
|
---|
67 |
|
---|
68 | public void setX(final int newX) {
|
---|
69 | this.x = newX;
|
---|
70 | }
|
---|
71 |
|
---|
72 | public void setY(final int newY) {
|
---|
73 | this.y = newY;
|
---|
74 | }
|
---|
75 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.