1 module xmain_d2d
is aliced
;
25 // ////////////////////////////////////////////////////////////////////////// //
30 // ////////////////////////////////////////////////////////////////////////// //
31 __gshared SimpleWindow sdwindow
;
34 public enum vlWidth
= 800;
35 public enum vlHeight
= 800;
36 __gshared
int scale
= 1;
37 __gshared
bool scanlines
= false;
40 // ////////////////////////////////////////////////////////////////////////// //
41 enum MaxLightRadius
= 512;
44 // ////////////////////////////////////////////////////////////////////////// //
46 __gshared FBO
[MaxLightRadius
+1] fboOccluders
, fboShadowMap
;
47 __gshared Shader shadToPolar
, shadBlur
;
49 __gshared FBO fboLevel
, fboOrigBack
;
50 __gshared Shader shadScanlines
;
51 __gshared Shader shadLiquidDistort
, shadLiquidColor
;
54 // ////////////////////////////////////////////////////////////////////////// //
56 glEnable(GL_TEXTURE_2D
);
57 glDisable(GL_LIGHTING
);
60 glDisable(GL_DEPTH_TEST
);
63 shadScanlines
= new Shader("scanlines", loadTextFile("data/shaders/srscanlines.frag"));
65 shadLiquidDistort
= new Shader("liquid_distort", loadTextFile("data/shaders/srliquid_distort.frag"));
66 shadLiquidDistort
.exec({ shadLiquidDistort
["tex0"] = 0; });
68 shadLiquidColor
= new Shader("liquid_color", loadTextFile("data/shaders/srliquid_color.frag"));
69 shadLiquidColor
.exec({ shadLiquidColor
["tex0"] = 0; });
72 shadToPolar
= new Shader("topolar", loadTextFile("data/shaders/srlight_topolar.frag"));
73 shadBlur
= new Shader("blur", loadTextFile("data/shaders/srlight_blur.frag"));
79 foreach (int sz
; 2..MaxLightRadius
+1) {
80 fboOccluders
[sz
] = new FBO(sz
*2, sz
*2, Texture
.Option
.Clamp
); // create occluders FBO
81 fboShadowMap
[sz
] = new FBO(sz
*2, 1, Texture
.Option
.Clamp
); // create 1d shadowmap FBO
85 glMatrixMode(GL_MODELVIEW
);
90 fboLevel
= new FBO(map
.width
*8, map
.height
*8, Texture
.Option
.Nearest
); // final level render will be here
91 fboOrigBack
= new FBO(map
.width
*8, map
.height
*8, Texture
.Option
.Nearest
); // original background
93 // build noise texture for liquid shaders
95 glActiveTexture(GL_TEXTURE0+1);
97 import std.random : uniform;
98 auto img = new TrueColorImage(64, 64);
99 foreach (int y; 0..img.width) {
100 foreach (int x; 0..img.height) {
101 ubyte b = cast(ubyte)uniform(0, 256);
102 img.imageData.colors[y*img.width+x] = Color(b, b, b, 255);
105 auto tex = new Texture(img);
110 glActiveTexture(GL_TEXTURE0
+0);
111 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT
, 0);
112 orthoCamera(vlWidth
, vlHeight
);
114 Actor
.resetStorage();
116 //map.initActors(); // this will precache sprites too
117 //map.doAllActorTicks();
119 { import core
.memory
: GC
; GC
.collect(); }
123 // ////////////////////////////////////////////////////////////////////////// //
124 void renderLight() (int lightX
, int lightY
, in auto ref SVec4F lcol
, int lightRadius
) {
125 if (lightRadius
< 2) return;
126 if (lightRadius
> MaxLightRadius
) lightRadius
= MaxLightRadius
;
127 int lightSize
= lightRadius
*2;
128 // is this light visible?
129 if (lightX
<= -lightRadius || lightY
<= -lightRadius || lightX
-lightRadius
>= map
.width
*8 || lightY
-lightRadius
>= map
.height
*8) return;
131 // draw shadow casters to fboOccludersId, light should be in the center
134 fboOccluders
[lightRadius
].exec({
135 glColor3f(0.0f, 0.0f, 0.0f);
136 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
137 glClear(GL_COLOR_BUFFER_BIT
);
138 orthoCamera(lightSize
, lightSize
);
139 drawAtXY(map
.texgl
.ptr
[map
.LightMask
], lightRadius
-lightX
, lightRadius
-lightY
);
142 // build 1d shadow map to fboShadowMapId
143 fboShadowMap
[lightRadius
].exec({
145 glColor3f(0.0f, 0.0f, 0.0f);
146 shadToPolar
["lightTexSize"] = SVec2F(lightSize
, lightSize
);
147 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
148 glClear(GL_COLOR_BUFFER_BIT
);
149 orthoCamera(lightSize
, 1);
150 drawAtXY(fboOccluders
[lightRadius
].tex
.tid
, 0, 0, lightSize
, 1);
157 shadBlur
["lightTexSize"] = SVec2F(lightSize
, lightSize
);
159 glBlendFunc(GL_SRC_ALPHA
, GL_ONE
);
161 glColor4f(lcol
.x
, lcol
.y
, lcol
.z
, lcol
.w
);
162 orthoCamera(map
.width
*8, map
.height
*8);
163 drawAtXY(fboShadowMap
[lightRadius
].tex
.tid
, lightX
-lightRadius
, lightY
-lightRadius
, lightSize
, lightSize
);
169 // ////////////////////////////////////////////////////////////////////////// //
170 __gshared
int lightX
= vlWidth
/2, lightY
= vlHeight
/2;
171 __gshared
int mapOfsX
, mapOfsY
;
172 __gshared
bool movement
= false;
175 void renderScene () {
176 enum BackIntens
= 0.05f;
182 glClearColor(BackIntens
, BackIntens
, BackIntens
, 1.0f);
183 glClear(GL_COLOR_BUFFER_BIT
);
186 // build background layer
190 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
191 glClear(GL_COLOR_BUFFER_BIT
);
192 //glEnable(GL_BLEND);
193 //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
194 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
195 orthoCamera(map
.width
*8, map
.height
*8);
197 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
200 drawAtXY(map.skytexgl.tid, mapOfsX/2-map.MapSize*8, mapOfsY/2-map.MapSize*8, map.MapSize*8, map.MapSize*8);
201 drawAtXY(map.skytexgl.tid, mapOfsX/2-map.MapSize*8, mapOfsY/2, map.MapSize*8, map.MapSize*8);
202 drawAtXY(map.skytexgl.tid, mapOfsX/2, mapOfsY/2-map.MapSize*8, map.MapSize*8, map.MapSize*8);
203 drawAtXY(map.skytexgl.tid, mapOfsX/2, mapOfsY/2, map.MapSize*8, map.MapSize*8);
205 drawAtXY(map
.skytexgl
.tid
, 0, 0, map
.MapSize
*8, map
.MapSize
*8);
207 drawAtXY(map
.texgl
.ptr
[map
.Back
], 0, 0);
208 // draw distorted liquid areas
209 shadLiquidDistort
.exec({
210 __gshared
float iGlobalTime
= 0.0;
212 shadLiquidDistort
["iGlobalTime"] = iGlobalTime
;
213 shadLiquidDistort
["liquidColorMul"] = SVec4F(1.0f, 1.0f, 1.0f, 1.0f);
214 drawAtXY(map
.texgl
.ptr
[map
.Water
], 0, 0);
215 shadLiquidDistort
["liquidColorMul"] = SVec4F(0.6f, 0.6f, 0.6f, 1.0f);
216 drawAtXY(map
.texgl
.ptr
[map
.Lava
], 0, 0);
217 shadLiquidDistort
["liquidColorMul"] = SVec4F(1.0f, 1.0f, 1.0f, 1.0f);
218 drawAtXY(map
.texgl
.ptr
[map
.Acid
], 0, 0);
221 glColor3f(1.0f, 1.0f, 1.0f);
223 foreach (auto actor; actors) {
224 if (actor.frame is null || actor.dead) continue;
225 //conwriteln("(", actor.x, ", ", actor.y, ") ", actor.frame.tex.tid, " ", actor.frame.tex.width, "x", actor.frame.tex.height);
226 //drawAtXY(actor.frame.tex, actor.x/*-actor.frame.vga.sx*/, actor.y/*-actor.frame.vga.sy*/);
227 //int y = LevelMap.MapSize*8-actor.y-1/*-(actor.height-actor.frame.vga.sy)*/;
228 //int y = LevelMap.MapSize*8-actor.y+(actor.frame.vga.sy-actor.frame.vga.height);
229 int y = actor.y-actor.frame.vga.sy;
230 drawAtXY(actor.frame.tex, actor.x-actor.frame.vga.sx, y);
233 Actor
.forEach((ActorId me
) {
234 // `act` is always valid here
235 if (auto adef
= findActorDef(me
.classtype
!StrId
, me
.classname
!StrId
)) {
236 if (auto isp
= adef
.animSpr(me
.zAnimstate
!StrId
, me
.dir
!uint, me
.zAnimidx
!int)) {
237 int y
= me
.y
!int-isp
.vga
.sy
;
238 drawAtXY(isp
.tex
, me
.x
!int-isp
.vga
.sx
, y
);
239 //conwriteln("found animation for actor ", me.id, " (", me.classtype!string, ":", me.classname!string, ")", " (", adef.fullname, ")");
241 conwriteln("no animation for actor ", me
.id
, " (", me
.classtype
!string
, ":", me
.classname
!string
, ")");
244 conwriteln("not found actor ", me
.id
, " (", me
.classtype
!string
, ":", me
.classname
!string
, ")");
251 glBlendFunc(GL_SRC_ALPHA
, GL_ONE
);
253 glActiveTexture(GL_TEXTURE0
+1);
254 glBindTexture(GL_TEXTURE_2D
, /*map.texgl.ptr[map.Back].tid*/fboOrigBack
.tex
.tid
);
255 //glBindTexture(GL_TEXTURE_2D, map.texgl.ptr[map.Back].tid);
256 glActiveTexture(GL_TEXTURE0
+0);
258 renderLight( 27, 391-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 100);
259 renderLight(542, 424-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 100);
260 renderLight(377, 368-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 32);
261 renderLight(147, 288-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 64);
262 renderLight( 71, 200-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 128);
263 renderLight(249, 200-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 128);
264 renderLight(426, 200-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 128);
265 renderLight(624, 200-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 128);
266 renderLight(549, 298-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 64);
267 renderLight( 74, 304-0, SVec4F(0.0f, 0.0f, 0.0f, 0.0f), 32);
269 renderLight(24*8+4, (24+18)*8-2, SVec4F(0.6f, 0.0f, 0.0f, 1.0f), 128);
270 foreach (immutable _
; 0..1) {
271 renderLight(lightX
, lightY
, SVec4F(0.3f, 0.3f, 0.0f, 1.0f), 256);
274 //glActiveTexture(GL_TEXTURE0+1);
275 //glBindTexture(GL_TEXTURE_2D, 0);
276 //glActiveTexture(GL_TEXTURE0+0);
278 // draw final opaque and full-lit parts
281 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
282 glColor3f(1.0f, 1.0f, 1.0f);
283 orthoCamera(map
.width
*8, map
.height
*8);
285 drawAtXY(map
.texgl
.ptr
[map
.LightMask
], 0, 0);
286 // foreground -- hide secrets, draw lifts and such
287 drawAtXY(map
.texgl
.ptr
[map
.Front
], 0, 0);
288 // now do liquid coloring
289 shadLiquidColor
.exec({
291 //glEnable(GL_BLEND);
292 // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
293 //glBlendFunc(GL_SRC_ALPHA, GL_ONE);
294 //glDisable(GL_BLEND);
295 //glColor3f(1.0f, 1.0f, 1.0f);
296 shadLiquidColor
["liquidColor"] = SVec4F(0.0f, 0.0f, 0.4f, 0.5f);
297 drawAtXY(map
.texgl
.ptr
[map
.Water
], 0, 0);
298 shadLiquidColor
["liquidColor"] = SVec4F(0.6f, 0.0f, 0.0f, 0.4f);
299 drawAtXY(map
.texgl
.ptr
[map
.Lava
], 0, 0);
300 shadLiquidColor
["liquidColor"] = SVec4F(0.1f, 0.4f, 0.0f, 0.5f);
301 drawAtXY(map
.texgl
.ptr
[map
.Acid
], 0, 0);
307 shadScanlines
["scanlines"] = scanlines
;
308 glClearColor(BackIntens
, BackIntens
, BackIntens
, 1.0f);
309 glClear(GL_COLOR_BUFFER_BIT
);
310 orthoCamera(vlWidth
, vlHeight
);
311 //orthoCamera(map.width*8*scale, map.height*8*scale);
312 //glMatrixMode(GL_MODELVIEW);
314 //glTranslatef(0.375, 0.375, 0); // to be pixel-perfect
315 // somehow, FBO objects are mirrored; wtf?!
316 drawAtXY(fboLevel
.tex
.tid
, -mapOfsX
, -mapOfsY
, map
.width
*8*scale
, map
.height
*8*scale
, mirrorY
:true);
322 // ////////////////////////////////////////////////////////////////////////// //
324 shared int diedie
= 0;
327 void renderThread () {
329 MonoTime prevFrameStartTime
= MonoTime
.currTime
;
330 version(use_vsync
) {} else MonoTime ltt
= MonoTime
.currTime
;
331 MonoTime lasttime
= MonoTime
.currTime
;
333 enum MaxFPSFrames
= 16;
334 float frtimes
= 0.0f;
339 if (sdwindow
.closed
) break;
340 if (atomicLoad(diedie
) > 0) break;
342 time
= MonoTime
.currTime
;
345 // max 60 FPS; capped by vsync
346 //{ import core.stdc.stdio; printf(" spent only %d msecs\n", cast(int)((time-ltt).total!"msecs")); }
347 if (!first
&& (time
-ltt
).total
!"msecs" < 16) {
348 //{ import core.stdc.stdio; printf(" spent only %d msecs\n", cast(int)((time-ltt).total!"msecs")); }
349 import core
.sys
.posix
.signal
: timespec
;
350 import core
.sys
.posix
.time
: nanosleep
;
353 ts
.tv_nsec
= (16-cast(int)((time
-ltt
).total
!"msecs"))*1000*1000; // milli to nano
354 nanosleep(&ts
, null); // idc how much time was passed
355 time
= MonoTime
.currTime
;
362 auto frameTime
= cast(float)(time
-prevFrameStartTime
).total
!"msecs"/1000.0f;
363 prevFrameStartTime
= time
;
365 //{ import core.stdc.stdio; printf("frametime: %f\n", frameTime*1000.0f); }
366 //{ import core.stdc.stdio; printf("FPS: %d\n", cast(int)(1.0f/frameTime)); }
367 frtimes
+= frameTime
;
368 if (++framenum
>= MaxFPSFrames || frtimes
>= 3.0f) {
369 import std
.string
: format
;
370 int newFPS
= cast(int)(cast(float)MaxFPSFrames
/frtimes
+0.5);
371 if (newFPS
!= prevFPS
) {
372 sdwindow
.title
= "%s / FPS:%s".format("D2D", newFPS
);
382 scope(exit
) sdwindow
.mtUnlock();
383 ctset
= sdwindow
.setAsCurrentOpenGlContextNT
;
386 { import core
.stdc
.stdio
; printf(" FUUUU\n"); }
387 //glXMakeCurrent(sdwindow.display, 0, null);
388 import core
.sys
.posix
.signal
: timespec
;
389 import core
.sys
.posix
.time
: nanosleep
;
392 ts
.tv_nsec
= 16*1000*1000; // milli to nano
393 nanosleep(&ts
, null); // idc how much time was passed
394 time
= MonoTime
.currTime
;
399 //map.doAllActorTicks();
404 scope(exit
) sdwindow
.mtUnlock();
405 sdwindow
.swapOpenGlBuffers();
407 sdwindow
.releaseCurrentOpenGlContext();
412 } catch (Exception e
) {
413 import core
.stdc
.stdio
;
414 fprintf(stderr
, "FUUUUUUUUUUUUUUUUUUUUUUUUUU\n");
416 if (sdwindow
.closed
) break;
417 if (atomicLoad(diedie
) > 0) break;
418 //{ import core.stdc.stdio; printf(" spent only %d msecs\n", cast(int)((time-ltt).total!"msecs")); }
419 import core
.sys
.posix
.signal
: timespec
;
420 import core
.sys
.posix
.time
: nanosleep
;
423 ts
.tv_nsec
= 100*1000*1000; // milli to nano
424 nanosleep(&ts
, null); // idc how much time was passed
427 atomicStore(diedie
, 2);
431 // ////////////////////////////////////////////////////////////////////////// //
432 void closeWindow () {
433 if (atomicLoad(diedie
) != 2) {
434 atomicStore(diedie
, 1);
435 while (atomicLoad(diedie
) != 2) {}
437 if (!sdwindow
.closed
) {
444 // ////////////////////////////////////////////////////////////////////////// //
445 __gshared Thread renderTid
;
448 void main (string
[] args
) {
449 FuncPool
.dumpCode
= false;
450 FuncPool
.dumpCodeSize
= false;
451 dacsDumpSemantic
= false;
453 bool compileOnly
= false;
455 for (usize idx
= 1; idx
< args
.length
; ++idx
) {
457 if (args
[idx
] == "--dump-code") FuncPool
.dumpCode
= true;
458 else if (args
[idx
] == "--dump-code-size") FuncPool
.dumpCodeSize
= true;
459 else if (args
[idx
] == "--dump-semantic") dacsDumpSemantic
= true;
460 else if (args
[idx
] == "--compile") compileOnly
= true;
461 else if (args
[idx
] == "--messages") ++dacsMessages
;
462 else if (args
[idx
].length
> 2 && args
[idx
][0..2] == "-O") {
463 import std
.conv
: to
;
464 ubyte olevel
= to
!ubyte(args
[idx
][2..$]);
465 dacsOptimize
= olevel
;
469 foreach (immutable c
; idx
+1..args
.length
) args
.ptr
[c
-1] = args
.ptr
[c
];
475 static void setDP () {
479 import std
.file
: thisExePath
;
480 import std
.path
: dirName
;
481 setDataPath(thisExePath
.dirName
);
483 addWad("/home/ketmar/k8prj/doom2d-tl/data/doom2d.wad"); loadWadScripts();
484 //addWad("/home/ketmar/k8prj/doom2d-tl/data/meat.wad"); loadWadScripts();
485 //addWad("/home/ketmar/k8prj/doom2d-tl/data/megadm.wad"); loadWadScripts();
486 //addWad("/home/ketmar/k8prj/doom2d-tl/data/megadm1.wad"); loadWadScripts();
487 //addWad("/home/ketmar/k8prj/doom2d-tl/data/superdm.wad"); loadWadScripts();
488 //addWad("/home/ketmar/k8prj/doom2d-tl/data/zadoomka.wad"); loadWadScripts();
493 if (compileOnly
) return;
498 setOpenGLContextVersion(3, 2); // up to GLSL 150
499 //openGLContextCompatible = false;
501 map
= new LevelMap("maps/map01.d2m");
505 map
.getThingPos(1/*ThingId.Player1*/, &mapOfsX
, &mapOfsY
);
507 mapOfsX
= (mapOfsX
*2)-vlWidth
/2;
508 if (mapOfsX
+vlWidth
> map
.width
*16) mapOfsX
= map
.width
*16-vlWidth
;
509 if (mapOfsX
< 0) mapOfsX
= 0;
510 mapOfsY
= (mapOfsY
*2)-vlHeight
/2;
511 if (mapOfsY
+vlHeight
> map
.height
*16) mapOfsY
= map
.height
*16-vlHeight
;
512 if (mapOfsY
< 0) mapOfsY
= 0;
515 sdwindow
= new SimpleWindow(vlWidth
, vlHeight
, "D2D", OpenGlOptions
.yes
, Resizablity
.fixedSize
);
517 sdwindow
.visibleForTheFirstTime
= delegate () {
518 sdwindow
.setAsCurrentOpenGlContext(); // make this window active
519 glbindLoadFunctions();
522 import core.stdc.stdio;
523 printf("GL version: %s\n", glGetString(GL_VERSION));
525 glGetIntegerv(GL_MAJOR_VERSION, &h);
526 glGetIntegerv(GL_MINOR_VERSION, &l);
527 printf("version: %d.%d\n", h, l);
528 printf("shader version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
530 glGetIntegerv(GL_NUM_SHADING_LANGUAGE_VERSIONS, &svcount);
532 printf("%d shader versions supported:\n", svcount);
533 foreach (GLuint n; 0..svcount) printf(" %d: %s\n", n, glGetStringi(GL_SHADING_LANGUAGE_VERSION, n));
537 glGetIntegerv(GL_NUM_EXTENSIONS, &ecount);
539 printf("%d extensions supported:\n", ecount);
540 foreach (GLuint n; 0..ecount) printf(" %d: %s\n", n, glGetStringi(GL_EXTENSIONS, n));
545 // check if we have sufficient shader version here
549 glGetIntegerv(GL_NUM_SHADING_LANGUAGE_VERSIONS
, &svcount
);
551 foreach (GLuint n
; 0..svcount
) {
552 import core
.stdc
.string
: strncmp
;
553 auto v
= glGetStringi(GL_SHADING_LANGUAGE_VERSION
, n
);
554 if (v
is null) continue;
555 if (strncmp(v
, "120", 3) != 0) continue;
556 if (v
[3] > ' ') continue;
561 if (!found
) assert(0, "can't find OpenGL GLSL 120");
563 auto adr
= glGetProcAddress("glTexParameterf");
564 if (adr
is null) assert(0);
567 sdwindow
.vsync
= false;
568 //sdwindow.useGLFinish = false;
570 //sdwindow.redrawOpenGlScene();
571 if (!sdwindow
.releaseCurrentOpenGlContext()) { import core
.stdc
.stdio
; printf("can't release OpenGL context(1)\n"); }
573 renderTid
= new Thread(&renderThread
);
578 //sdwindow.redrawOpenGlScene = delegate () { renderScene(); };
580 enum MSecsPerFrame
= 1000/30; /* 30 is FPS */
582 uint[8] frameTimes
= 1000;
583 enum { Left
, Right
, Up
, Down
}
584 bool[4] pressed
= false;
586 sdwindow
.eventLoop(MSecsPerFrame
,
588 if (sdwindow
.closed
) return;
589 if (pressed
[Left
]) mapOfsX
-= 8;
590 if (pressed
[Right
]) mapOfsX
+= 8;
591 if (pressed
[Up
]) mapOfsY
-= 8;
592 if (pressed
[Down
]) mapOfsY
+= 8;
593 import std
.math
: cos
, sin
;
594 __gshared
float itime
= 0.0;
597 mapOfsX
= cast(int)(800.0/2.0+cos(itime
)*220.0);
598 mapOfsY
= cast(int)(800.0/2.0+120.0+sin(itime
)*160.0);
600 if (scale
== 1) mapOfsX
= mapOfsY
= 0;
601 //sdwindow.redrawOpenGlSceneNow();
603 delegate (KeyEvent event
) {
604 if (sdwindow
.closed
) return;
605 if (event
.pressed
&& event
.key
== Key
.Escape
) { closeWindow(); return; }
607 case Key
.Left
: pressed
[Left
] = event
.pressed
; break;
608 case Key
.Right
: pressed
[Right
] = event
.pressed
; break;
609 case Key
.Up
: pressed
[Up
] = event
.pressed
; break;
610 case Key
.Down
: pressed
[Down
] = event
.pressed
; break;
614 delegate (MouseEvent event
) {
615 lightX
= event
.x
/scale
;
616 lightY
= event
.y
/scale
;
617 lightX
+= mapOfsX
/scale
;
618 lightY
+= mapOfsY
/scale
;
620 delegate (dchar ch
) {
621 if (ch
== 'q') { closeWindow(); return; }
622 if (ch
== 's') scanlines
= !scanlines
;
623 if (ch
== '1') scale
= 1;
624 if (ch
== '2') scale
= 2;
625 if (ch
== ' ') movement
= !movement
;