-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKickBall.java
More file actions
148 lines (132 loc) · 4.47 KB
/
KickBall.java
File metadata and controls
148 lines (132 loc) · 4.47 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class KickBall {
/**
* KickBall class of Slide Into Highschool, creates KickBall game
*
* <h2>Course Info:</h2>
* ICS4UP with Krasteva, V.
* Date: June 7th, 2023
* Time Spent: 1 hrs
* @version 1
* @author Charlie To, Milena Mofrad
*/
JFrame frame;
public static int x=0;
public static int y = 0;
public static int xPos = 0;
public static int yPos =0;
public static int stage =1;
public static int score =0;
public static boolean isComplete = false;
/**
* Constructor method
*
* @param frame Takes JGrasp frame
*/
public KickBall(JFrame frame) {
this.frame = frame;
// frame.addMouseListener(new ClickHandler());
// Clear the frame
Container contentPane = frame.getContentPane();
contentPane.removeAll();
this.frame.revalidate();
this.frame.repaint();
MainMenu.setIsKickBall(true);
}
public void run() {
frame.getContentPane().add(new Drawing());
frame.setVisible(true);
}
class Drawing extends JComponent {
public void paint(Graphics g) {
super.paintComponent(g);
// BACKGROUND
g.setColor(Colours.backgroundBlue);
g.fillRect(0, 0, getWidth(), getHeight());
// GRASS
g.setColor(new Color (40,200,40));
g.fillRect(0,400,800,100);
//BALL
g.setColor(new Color (200,200,100));
g.fillOval(350,380,100,100);
// WORDS
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 50));
g.drawString("KICK THE BALL", 200, 70);
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 20));
g.drawString("Click inside the goal to kick", 200, 140);
if (stage == 1) {
//GATE
g.setColor(Color.GRAY);
g.fillRect(100,200,600,40);
g.fillRect(100,200,40,200);
g.fillRect(660,200,40,200);
} else if (stage == 2) {
// BACKGROUND
g.setColor(Colours.backgroundBlue);
g.fillRect(0, 0, getWidth(), getHeight());
// GRASS
g.setColor(new Color (40,200,40));
g.fillRect(0,400,800,100);
// WORDS
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 50));
g.drawString("KICK THE BALL", 200, 70);
//BALL
g.setColor(new Color (200,200,100));
g.fillOval(350,380,100,100);
//GATE
g.setColor(Color.GRAY);
g.fillRect(200,250,400,40);
g.fillRect(200,250,40,150);
g.fillRect(560,250,40,150);
} else if (stage == 3) {
// BACKGROUND
g.setColor(Colours.backgroundBlue);
g.fillRect(0, 0, getWidth(), getHeight());
// GRASS
g.setColor(new Color (40,200,40));
g.fillRect(0,400,800,100);
// WORDS
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 50));
g.drawString("KICK THE BALL", 200, 70);
//BALL
g.setColor(new Color (200,200,100));
g.fillOval(350,380,100,100);
//GATE
g.setColor(Color.GRAY);
g.fillRect(300,300,200,40);
g.fillRect(300,300,40,100);
g.fillRect(460,300,40,100);
} else if (stage == 4) {
g.setColor(Colours.backgroundBlue);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.BLACK);
g.fillRect(100,100,600,300);
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 25));
if(score>=2){
g.drawString("Congratulations!", 200, 230);
g.drawString("You have successfully", 200, 280);
g.drawString("kicked a ball!", 200, 330);
}else{
g.drawString("Oh no!", 200, 230);
g.drawString("You did not kick the", 200, 280);
g.drawString("ball successfully!", 200, 330);
}
g.setColor(Color.BLACK);
g.fillRect(300,420,200,60);
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 15));
g.drawString("Continue", 330, 440);
}else {
System.out.println("done");
KickBall.isComplete = true;
}
}
}
}