-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquare.java
43 lines (36 loc) · 1.22 KB
/
Square.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
36
37
38
39
40
41
42
43
package org.cis120.tetris;
/**
* CIS 120 Game HW
* (c) University of Pennsylvania
*
* @version 2.1, Apr 2017
*/
import java.awt.*;
/**
* A basic game object starting in the upper left corner of the game court. It
* is displayed as a square of a specified color.
*/
public class Square extends GameObj {
public static final int SIZE = 30;
public static final int INIT_POS_X = 0;
public static final int INIT_POS_Y = 0;
public static final int INIT_VEL_X = 0;
public static final int INIT_VEL_Y = 0;
public static final int COURT_WIDTH = 300;
public static final int COURT_HEIGHT = 600;
private Color color;
/**
* Note that, because we don't need to do anything special when constructing
* a Square, we simply use the superclass constructor called with the
* correct parameters.
*/
public Square(int xCord, int yCord, Color color) {
super(INIT_VEL_X, INIT_VEL_Y, xCord, yCord, SIZE, SIZE, COURT_WIDTH, COURT_HEIGHT);
this.color = color;
}
@Override
public void draw(Graphics g) {
g.setColor(this.color);
g.fillRect(this.getPx(), this.getPy(), this.getWidth(), this.getHeight());
}
}