-
Notifications
You must be signed in to change notification settings - Fork 0
/
BarrageLCL.pde
155 lines (123 loc) · 2.51 KB
/
BarrageLCL.pde
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
左クリックドラッグ 回転
ホイールクリックドラッグ 平行移動
右クリック 位置リセット
スクロール 拡大縮小
スペース 軸表示
esc 編集切り替え
*/
boolean isCtrl;
boolean isCmd;
boolean isAlt;
boolean isShift;
final int WINDOW_WIDTH = 1200;
final int WINDOW_HEIGHT = 800;
final int FPS = 60;
final float SPF = 1.0 / FPS;
CameraController cameraController = new CameraController();
boolean showAxis = false;
boolean editMode = false;
CodeEditor editor;
Runner runner;
DSLAnalyzer analyzer;
void settings() {
size(WINDOW_WIDTH, WINDOW_HEIGHT, P3D);
}
void setup() {
noStroke();
lights();
hint(ENABLE_KEY_REPEAT);
StaticContext ctx = makeStaticContext();
runner = new Runner(this, ctx);
analyzer = new DSLAnalyzer(runner, ctx);
editor = new CodeEditor();
editor.codeAnalyzer = analyzer;
editor.editorListener = new SEPlayerEditorListener(this);
String sample = readFileAll("sample.txt");
editor.setText(sample);
}
void draw() {
runner.update();
if (frameCount % 2 != 0) {
return;
}
// =====
hint(ENABLE_DEPTH_TEST);
background(0, 0, 0);
cameraController.draw();
PVector cameraPoint = cameraController.getPoint();
if (showAxis) {
strokeWeight(2);
stroke(255, 0, 0);
line(0, 0, 0, 300, 0, 0);
stroke(0, 255, 0);
line(0, 0, 0, 0, 300, 0);
stroke(0, 0, 255);
line(0, 0, 0, 0, 0, 300);
noStroke();
}
runner.draw(cameraPoint);
// ===
camera();
hint(DISABLE_DEPTH_TEST);
if (editMode) {
editor.draw(WINDOW_WIDTH, WINDOW_HEIGHT);
}
}
void mousePressed() {
cameraController.mousePressed();
}
void mouseDragged() {
cameraController.mouseDragged();
}
void mouseWheel(MouseEvent event) {
cameraController.mouseWheel(event);
}
void keyPressed() {
if (keyCode == CONTROL) {
isCtrl = true;
}
if (keyCode == 157) {
isCmd = true;
}
if (keyCode == ALT) {
isAlt = true;
}
if (keyCode == SHIFT) {
isShift = true;
}
if (editMode) {
boolean isQuit = editor.keyPressed();
if (isQuit) {
editMode = false;
}
} else {
if (key == ESC) {
editMode = true;
} else if (key == ' ') {
showAxis = !showAxis;
}
}
if (key == ESC) {
key = 0;
}
}
void keyTyped() {
if (editMode) {
editor.keyTyped();
}
}
void keyReleased() {
if (keyCode == CONTROL) {
isCtrl = false;
}
if (keyCode == 157) {
isCmd = false;
}
if (keyCode == ALT) {
isAlt = false;
}
if (keyCode == SHIFT) {
isShift = false;
}
}