-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEscapeMap.java
More file actions
133 lines (127 loc) · 4.87 KB
/
EscapeMap.java
File metadata and controls
133 lines (127 loc) · 4.87 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
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
/**
* EscapeMap class of Slide Into Highschool, Map for Escape stage of game
*
* <h2>Course Info:</h2>
* ICS4UP with Krasteva, V.
* Date: June 6st, 2023
* Time Spent: 2.5 hrs
* @version 1
* @author Charlie To, Milena Mofrad
*/
public class EscapeMap {
/** frame variable*/
JFrame frame;
/** text variable for exit button*/
public static String text = "Exit";
/** checks if the hall level is complete*/
public static boolean isHallComplete = false;
/** checks if the take notes level is complete*/
public static boolean isTakeNotesComplete = false;
/** checks if the talk to teacher level is complete*/
public static boolean isTalkToTeacherComplete = false;
/** checks if the kick the ball level is complete*/
public static boolean isKickBallComplete = false;
/** check is the library game is complete*/
public static boolean isLibraryGameComplete = false;
/**
* Constructor method
*
* @param frame Takes frame from driver
*/
public EscapeMap(JFrame frame) {
this.frame = frame;
// Clear the frame
Container contentPane = frame.getContentPane();
contentPane.removeAll();
this.frame.revalidate();
this.frame.repaint();
MainMenu.setIsEscapeMap(true);
}
/**
* run method
*
*/
public void run(){
ImageIcon map = new ImageIcon("images/map.png", "image of map");
frame.add(new JLabel(map));
frame.getContentPane().add(new Drawing());
frame.setVisible(true);
}
/** holds the x position*/
public static int xPos = 640;
/** holds the y position */
public static int yPos = 170;
/**
* Drawing class
*
*/
class Drawing extends JComponent {
/**
* paint method
*
* @param g Takes Graphics class
*/
public void paint(Graphics g) {
super.paintComponent(g);
// BACKGROUND MAP
try{
BufferedImage img = ImageIO.read(new File("images/map.png"));
g.drawImage(img, 0, 0, null);
} catch (Exception e){System.out.println("Error with image");}
// BACKGROUND PERSON
try{
BufferedImage img = ImageIO.read(new File("images/person.png"));
Image newImage = img.getScaledInstance(40, 70, Image.SCALE_DEFAULT);
g.drawImage(newImage, xPos, yPos, null);
} catch (Exception e){System.out.println("Error with image");}
g.setColor(Color.GREEN);
g.fillRect(80, 360, 210, 70);
g.setColor(Color.BLACK);
g.setFont(new Font("roboto", Font.BOLD, 22));
g.drawString(text, 80, 405);
if(isHallComplete){
try{
BufferedImage img = ImageIO.read(new File("images/check.png"));
Image newImage = img.getScaledInstance(50, 50, Image.SCALE_DEFAULT);
g.drawImage(newImage, 402, 170, null);
} catch (Exception e){System.out.println("Error with image");}
}
if(isTakeNotesComplete){
try{
BufferedImage img = ImageIO.read(new File("images/check.png"));
Image newImage = img.getScaledInstance(50, 50, Image.SCALE_DEFAULT);
g.drawImage(newImage, 352, 107, null);
} catch (Exception e){System.out.println("Error with image");}
}
if(isTalkToTeacherComplete){
try{
BufferedImage img = ImageIO.read(new File("images/check.png"));
Image newImage = img.getScaledInstance(50, 50, Image.SCALE_DEFAULT);
g.drawImage(newImage, 240, 280, null);
} catch (Exception e){System.out.println("Error with image");}
}
if(isKickBallComplete){
try{
BufferedImage img = ImageIO.read(new File("images/check.png"));
Image newImage = img.getScaledInstance(50, 50, Image.SCALE_DEFAULT);
g.drawImage(newImage, 400, 340, null);
} catch (Exception e){System.out.println("Error with image");}
}
if(isLibraryGameComplete){
try{
BufferedImage img = ImageIO.read(new File("images/check.png"));
Image newImage = img.getScaledInstance(50, 50, Image.SCALE_DEFAULT);
g.drawImage(newImage, 575, 370, null);
} catch (Exception e){System.out.println("Error with image");}
}
g.setColor(Color.WHITE);
g.setFont(Colours.title);
g.drawString("Escape Level: Survive a School Day", 90, 40);
}
}
}