-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
72 lines (72 loc) · 3.07 KB
/
Main.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
public class Main{
public static void main(String[] args){
java.io.PrintWriter out = new java.io.PrintWriter(System.out);
Reader in = new Reader();
out.println("Enter mode:\n1. tile map editor\n2. test tile map and overlay\n3. test tile map and overlay with TUI");
out.flush();
int mode = 0;
try{mode = in.nextInt();}catch(Exception e){e.printStackTrace();}
if(mode==1){
Tilemapmgr.makeMap();
out.print("Enter map name to draw:");
out.flush();
try{out.println(Tilemapmgr.draw(in.readLine().strip()));}catch(Exception e){e.printStackTrace();}
}else if(mode==2){
Tilemapmgr.loadFromImage("test", "C:\\Users\\shunt\\apcs\\CSQuest\\tilemaps\\test.png");
RenderedMap map=Tilemapmgr.draw("test");
int x=8, y=8;
String input="";
OUTER:
while (true) {
map=Tilemapmgr.draw("test", x-2, y-2, 10, 10);
map.overlay(new RenderedMap(2, 4, 'X'), 4, 5);
out.println(map);
out.flush();
try{input=in.readLine();}catch(Exception e){e.printStackTrace();}
switch (input) {
case "w" -> y--;
case "s" -> y++;
case "a" -> x--;
case "d" -> x++;
case "q" -> {
break OUTER;
}
default -> {
}
}
}
}else if(mode==3){
Tilemapmgr.loadFromImage("test", "C:\\Users\\shunt\\apcs\\CSQuest\\tilemaps\\test.png");
Tilemapmgr.activate();
Graphicsmgr gm = new Graphicsmgr(true);
gm.makePanel("Tilemap");
gm.makeTextArea("Tilemap");
gm.panel.setSize(800, 800);
gm.frame.setSize(800, 800);
gm.frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
gm.frame.setVisible(true);
gm.panel.setVisible(true);
gm.panel.setFocusable(true);
gm.panel.requestFocus();
gm.draw();
gm.panel.addKeyListener(new java.awt.event.KeyAdapter(){
int x = 8, y = 8;
@Override
public void keyPressed(java.awt.event.KeyEvent e){
RenderedMap map = Tilemapmgr.draw("test", x-2, y-2, 10, 10);
map.overlay(new RenderedMap(2, 4, 'X'), 4, 5);
((javax.swing.JTextArea)gm.getComponent("Tilemap")).setText(map.toString());
switch(e.getKeyCode()){
case java.awt.event.KeyEvent.VK_W -> y--;
case java.awt.event.KeyEvent.VK_S -> y++;
case java.awt.event.KeyEvent.VK_A -> x--;
case java.awt.event.KeyEvent.VK_D -> x++;
case java.awt.event.KeyEvent.VK_Q -> System.exit(0);
}
gm.draw();
}
});
}
out.flush();
}
}