This repository was archived by the owner on Sep 17, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathEngine.java
More file actions
119 lines (91 loc) · 2.7 KB
/
Copy pathEngine.java
File metadata and controls
119 lines (91 loc) · 2.7 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
package Gprocessing.util;
import Gprocessing.graphics.Window;
import org.lwjgl.glfw.GLFWErrorCallback;
import static org.lwjgl.glfw.GLFW.glfwInit;
public class Engine {
/**
* Engine contains static core methods that Gprocessing projects may access
* also initializes the window and game loop
*/
private static long startMillis = System.currentTimeMillis();
public static Window w;
public static boolean running = true;
public static float deltaTime = 0;
public static boolean showEditor = false;
/**
* Start the engine, and initialize GLFW.
* @param windowWidth Width of the window to be created
* @param windowHeight Height of the window to be created
* @param windowTitle Title of the window to be created
* @param se Boolean to show the editor or not
*/
public static void init(int windowWidth, int windowHeight, String windowTitle, boolean se) {
showEditor = se;
GLFWErrorCallback.createPrint(System.err).set();
if (!glfwInit())
throw new IllegalStateException("[FATAL] Failed to initialize GLFW.");
w = new Window(windowWidth, windowHeight, windowTitle);
w.showWindow();
}
/**
* Start the engine, and initialize GLFW.
* @param windowWidth Width of the window to be created
* @param windowHeight Height of the window to be created
* @param windowTitle Title of the window to be created
*/
public static void init(int windowWidth, int windowHeight, String windowTitle) {
GLFWErrorCallback.createPrint(System.err).set();
if (!glfwInit())
throw new IllegalStateException("[FATAL] Failed to initialize GLFW.");
w = new Window(windowWidth, windowHeight, windowTitle);
w.showWindow();
}
/**
* @return Returns the number of milliseconds since the engine started.
*/
public static double millis() {
return System.currentTimeMillis() - startMillis;
}
/**
* Wraps around System.out.println.
* @param s String to print
*/
public static void println(String s) {
System.out.println(s);
}
/**
* Wraps around System.out.println.
* @param i int to print
*/
public static void println (int i) {
System.out.println(i);
}
/**
* Wraps around System.out.println.
* @param f float to print
*/
public static void println (float f) {
System.out.println(f);
}
/**
* println with prefixed "[ERROR] "
* @param s String to print
*/
public static void printError (String s) {
System.out.println("[ERROR] " + s);
}
/**
* println with prefixed "[WARNING] "
* @param s String to print
*/
public static void printWarning (String s) {
System.out.println("[WARNING] " + s);
}
/**
* println with prefixed "[INFO] "
* @param s String to print
*/
public static void printInfo (String s) {
System.out.println("[INFO] " + s);
}
}