-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSprite.java
More file actions
38 lines (29 loc) · 1.02 KB
/
Sprite.java
File metadata and controls
38 lines (29 loc) · 1.02 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
import java.awt.Color;
import java.awt.Graphics;
public abstract class Sprite {
private int x;
private int y;
private int squareSize;
public Sprite(int x, int y, int squareSize) {
this.x = x;
this.y = y;
this.squareSize = squareSize;
}
public int getX() { return x; }
public int getY() { return y; }
public int getSquareSize() { return squareSize; }
public void setX(int x) { this.x = x; }
public void setY(int y) { this.y = y; }
public void setPosition(int x, int y) {
this.x = x;
this.y = y;
}
public void drawSquare(Graphics g, int blockX, int blockY, Color color) {
g.setColor(color);
g.fillRect(blockX, blockY, squareSize, squareSize);
g.setColor(Color.BLACK);
g.drawRect(blockX, blockY, squareSize, squareSize);
}
// Removed the abstract draw(Graphics g) method to allow Grid and Piece
// to have completely tailored parameter inputs.
}