-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLearningLevel.java
More file actions
82 lines (78 loc) · 3.13 KB
/
LearningLevel.java
File metadata and controls
82 lines (78 loc) · 3.13 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
import javax.swing.*;
import java.awt.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
public class LearningLevel {
/**
* LearningClassroom class of Slide Into Highschool, creates learning classroom graphics for learning stage
*
* <h2>Course Info:</h2>
* ICS4UP with Krasteva, V.
* Date: June 4st, 2023
* Time Spent: 0.5 hrs
* @version 1
* @author Charlie To, Milena Mofrad
*/
JFrame frame;
public static int cur = 1;
public static String text = "Welcome to the learning level! Click the circled items to learn about them.";
public static String text2 = "Click 'Next Room' after you've learnt about all the different items in the room";
/**
* Constructor method
*
* @param frame Takes JGrasp frame
*/
public LearningLevel(JFrame frame){
this.frame = frame;
// Clear the frame
Container contentPane = frame.getContentPane();
contentPane.removeAll();
this.frame.revalidate();
this.frame.repaint();
MainMenu.setIsLearningLevel(true);
}
public static void resetVars(){
cur = 1;
text = "Welcome to the learning level! Click the circled items to learn about them.";
text2 = "Click 'Next Room' after you've learnt about all the different items in the room";
}
public void run(){
frame.getContentPane().add(new Drawing());
frame.setVisible(true);
}
class Drawing extends JComponent {
public void paint(Graphics g) {
super.paintComponent(g);
if (cur == 1){
try{
BufferedImage img = ImageIO.read(new File("images/learning/NewLearningHallway.png"));
// Image newImage = img.getScaledInstance(img.getWidth(), img., Image.SCALE_DEFAULT);
g.drawImage(img, 0, 0, null);
} catch (Exception e){System.out.println("Error with image");}
}
if (cur == 2){
try{
BufferedImage img = ImageIO.read(new File("images/learning/NewLearningClassroom.png"));
// Image newImage = img.getScaledInstance(img.getWidth(), img., Image.SCALE_DEFAULT);
g.drawImage(img, 0, 0, null);
} catch (Exception e){System.out.println("Error with image");}
}
if (cur == 3){
try{
BufferedImage img = ImageIO.read(new File("images/learning/NewLearningCaf.png"));
// Image newImage = img.getScaledInstance(img.getWidth(), img., Image.SCALE_DEFAULT);
g.drawImage(img, 0, 0, null);
} catch (Exception e){System.out.println("Error with image");}
}
g.setColor(Colours.darkerBlue);
g.fillRoundRect(100-10, 400-10, 580+20, 100+20, 20, 20);
g.setColor(Color.WHITE);
g.fillRoundRect(100-3, 400-3, 580+6, 100+6, 20, 20);
g.setColor(Color.BLACK);
g.setFont(new Font("Roboto", Font.PLAIN, 17));
g.drawString(text,100+10, 400+25);
g.drawString(text2,100+10, 400+30+20);
}
}
}