-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBorders.java
More file actions
32 lines (28 loc) · 892 Bytes
/
Borders.java
File metadata and controls
32 lines (28 loc) · 892 Bytes
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
//importing packages
import javax.swing.*;
import java.awt.Graphics;
import java.awt.Color;
public class Borders extends JPanel
{
int p1Score = 0;//creating a variable called p1Score to track player 1 score and setting it equal to 0 to start
int p2Score = 0;//creating a variable called p2Score to track player 2 score and setting it equal to 0 to start
public void drawBorder(Graphics g)
{
//point borders, left and right
g.setColor(Color.RED);
g.fillRect(0,0,5,340);
g.fillRect(565,0,5,350);
//bounce borders, top and bottom
g.setColor(Color.GRAY);
g.fillRect(0,0,565,10);
g.fillRect(0,340,565,10);
//Show scores
g.drawString(Integer.toString(p1Score), 263, 20);
g.drawString(Integer.toString(p2Score), 295, 20);
}
void resetScore()//procedure to reset scores of both players
{
this.p1Score = 0;
this.p2Score = 0;
}
}