-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathRunApp.java
84 lines (75 loc) · 2.55 KB
/
RunApp.java
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
import fallk.logmaster.HLogger;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
class RunApp extends Panel {
/**
*
*/
private static final long serialVersionUID = -8590687589434803725L;
private static Frame frame;
private static GameSparker applet;
private static ArrayList<Image> icons;
/**
* Fetches icons of 16, 32 and 48 pixels from the 'data' folder.
*
* @return icons - ArrayList of icon locations
*/
private static ArrayList<Image> getIcons() {
if (icons == null) {
icons = new ArrayList<>();
int[] resols = {
16, 32, 48
};
for (int res : resols) {
icons.add(Toolkit.getDefaultToolkit().createImage("data/ico_" + res + ".png"));
}
}
return icons;
}
public static void main(String[] strings) {
System.runFinalizersOnExit(true);
HLogger.info("UNFM2 Console"); // Change this to the message of your preference
try {
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {
HLogger.warn("Could not setup System Look&Feel: " + ex.toString());
}
startup();
}
private static void startup() {
frame = new Frame("UNFM2");// Change this to the name of your preference
frame.setBackground(new Color(0, 0, 0));
frame.setIgnoreRepaint(true);
frame.setIconImages(getIcons());
applet = new GameSparker();
applet.setStub(new DesktopStub());
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent windowevent) {
exitSequence();
}
});
applet.setPreferredSize(new Dimension(670, 400));// The resolution of your game goes here
frame.add("Center", applet);
frame.setResizable(false);// If you plan to make you game support changes in resolution, you can comment out this line.
frame.pack();
frame.setMinimumSize(frame.getSize());
frame.setLocationRelativeTo(null);
frame.setVisible(true);
applet.init();
applet.start();
}
private static void exitSequence() {
applet.stop();
frame.removeAll();
try {
Thread.sleep(200L);
} catch (Exception exception) {
}
applet.destroy();
applet = null;
System.exit(0);
}
}