-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryGame.java
More file actions
148 lines (141 loc) · 4.34 KB
/
LibraryGame.java
File metadata and controls
148 lines (141 loc) · 4.34 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 LibraryGame {
/**
* LibraryGame class of Slide Into Highschool, creates the library game for the escape stage of game
*
* <h2>Course Info:</h2>
* ICS4UP with Krasteva, V.
* Date: June 7th, 2023
* Time Spent: 2 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 int x1, x2, y1, y2;
public static boolean[] books= new boolean[6];
public static boolean isComplete = false;
/**
* Constructor method
*
* @param frame Takes JGrasp frame
*/
public LibraryGame(JFrame frame) {
this.frame = frame;
x1 = 120;
x2 = 200;
y1 = 120;
y2 = 240;
// frame.addMouseListener(new ClickHandler());
// Clear the frame
Container contentPane = frame.getContentPane();
contentPane.removeAll();
this.frame.revalidate();
this.frame.repaint();
MainMenu.setIsLibraryGame(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());
// LOCKER
g.setColor(Color.BLACK);
g.fillRect(100,100,300,300);
g.setColor(Color.GRAY);
g.fillRect(110,110,280,130);
g.fillRect(110,260,280,130);
//BOOKS
g.setColor(Color.RED);
if(books[0]) g.setColor(Color.GRAY);
g.fillRect(120,120,80,120);
g.setColor(new Color(40,250,100));
if(books[1]) g.setColor(Color.GRAY);
g.fillRect(200,120,60,120);
g.setColor(new Color(240,100,210));
if(books[2]) g.setColor(Color.GRAY);
g.fillRect(260,180,120,60);
g.setColor(Color.GREEN);
if(books[3]) g.setColor(Color.GRAY);
g.fillRect(120,330,130,60);
g.setColor(Color.YELLOW);
if(books[4]) g.setColor(Color.GRAY);
g.fillRect(250,270,70,120);
g.setColor(Color.PINK);
if(books[5]) g.setColor(Color.GRAY);
g.fillRect(320,280,60,110);
// WORDS
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 50));
g.drawString("GET THE RIGHT BOOKS", 200, 70);
if (stage == 1) {
g.setColor(Color.RED);
g.fillRect(500,100,200,300);
} else if (stage == 2) {
x1 = 250;
x2 = 320;
y1 = 270;
y2 = 390;
g.setColor(Color.YELLOW);
g.fillRect(500,100,200,300);
} else if (stage == 3) {
x1 = 120;
x2 = 250;
y1 = 330;
y2 = 390;
g.setColor(Color.GREEN);
g.fillRect(500,100,200,300);
} else if (stage == 4) {
x1 = 320;
x2 = 380;
y1 = 280;
y2 = 390;
g.setColor(Color.PINK);
g.fillRect(500,100,200,300);
} else if (stage == 5) {
x1 = 260;
x2 = 380;
y1 = 180;
y2 = 240;
g.setColor(new Color(240,100,210));
g.fillRect(500,100,200,300);
} else if (stage == 6) {
x1 = 200;
x2 = 260;
y1 = 120;
y2 = 240;
g.setColor(new Color(40,250,100));
g.fillRect(500,100,200,300);
}else if (stage == 7) {
x1 = 0;
x2 = 0;
y1 = 0;
y2 = 0;
g.setColor(Color.BLACK);
g.fillRect(100,100,600,300);
g.setColor(Color.WHITE);
g.setFont(new Font("Roboto", Font.PLAIN, 30));
g.drawString("Congratulations, you have picked", 200, 200);
g.drawString("all the right book for yourself", 200, 300);
g.drawString("Continue", 350, 380);
System.out.println("done");
LibraryGame.isComplete = true;
}else if (stage > 7) {
System.out.println("done");
LibraryGame.isComplete = true;
}
}
}
}