forked from Dason-IsopodOverseer/Wrong-Galaxy-Beta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSprite.java
35 lines (27 loc) · 914 Bytes
/
Sprite.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
/* Sprite.java
* March 23, 2006
* Store no state information, this allows the image to be stored only
* once, but to be used in many different places. For example, one
* copy of alien.gif can be used over and over.
*/
import java.awt.Graphics;
import java.awt.Image;
public class Sprite {
public Image image; // the image to be drawn for this sprite
// constructor
public Sprite (Image i) {
image = i;
} // constructor
// return width of image in pixels
public int getWidth() {
return image.getWidth(null);
} // getWidth
// return height of image in pixels
public int getHeight() {
return image.getHeight(null);
} // getHeight
// draw the sprite in the graphics object provided at location (x,y)
public void draw(Graphics g, int x, int y) {
g.drawImage(image, x, y, null);
} // draw
} // Sprite