-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMain.java
More file actions
98 lines (74 loc) · 3.13 KB
/
Copy pathMain.java
File metadata and controls
98 lines (74 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import com.javagamemaker.javagameengine.JavaGameEngine;
import com.javagamemaker.javagameengine.Scene;
import com.javagamemaker.javagameengine.components.Component;
import com.javagamemaker.javagameengine.input.Input;
import com.javagamemaker.javagameengine.input.Keys;
import com.javagamemaker.javagameengine.msc.Debug;
import com.javagamemaker.javagameengine.msc.Vector2;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
/*
user can add script
this will create default java class that extends component
when that file is updated we build it and add it to a game jar file (javagameneinge jar)
when the script is placed on a component a temporary file will be created
this file will state which component (with index) should have this component
when the game starts this file gets removed and the scene will add the component to the
selected components
*/
public class Main extends JavaGameEngine {
public static void main(String[] args){
Scene scene1 = new Scene(){
@Override
public void start() {
super.start();
getCamera().setScale(new Vector2(2,2));
//getCamera().setPosition(new Vector2(100,0));
}
@Override
public void debugUpdate() {
super.debugUpdate();
if(Input.isKeyPressed(Keys.ESCAPE)){
setDebugMode(false);
}
}
};
try{
scene1.load();
}catch (Exception e){
}
// Create a File object on the root of the directory containing the class file
//File file = new File("/home/spy/dev/java/Test/out/production/Test/Player.class");
//File file = new File("/home/spy/dev/java/JavaGameEngine/out/production/JavaGameEngine/Player.class");
String scriptFiles = "/home/spy/dev/java/JavaGameEngine/out/artifacts/edit/scripts";
/*
File folder = new File(scriptFiles);
for( File file : folder.listFiles() ){
if(file.getName().contains(".class")) {
try {
// Convert File to a URL
URL url = file.toURI().toURL(); // file:/c:/myclasses/
URL[] urls = new URL[]{url};
// Create a new class loader with the directory
ClassLoader cl = new URLClassLoader(urls);
// Load in the class; MyClass.class should be located in
// the directory file:/c:/myclasses/com/mycompany
Class cls = cl.loadClass("Player");
Component c = (Component) cls.newInstance();
c.update();
scene1.getComponents1().get(0).add(c);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
*/
Debug.log(scene1.getComponents1().size());
scene1.setDebugMode(true);
// scene1.add(new GameObject());
setSelectedScene(scene1);
JavaGameEngine.size = new Vector2(1920/2,1080/2);
start();
}
}