1 /* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import arsd
.simpledisplay
;
26 // ////////////////////////////////////////////////////////////////////////// //
27 void main (string
[] args
) {
28 //vfsAddPak("data/mminer.wad");
29 registerWad("data/mminer.wad");
31 for (int idx
= 1; idx
< args
.length
; ++idx
) {
32 if (args
[idx
] == "-file") {
33 if (args
.length
-idx
< 2) assert(0, "arg?!");
34 registerWad(args
[idx
+1]);
37 assert(0, "invalid arg");
45 void loadRoom (int idx
) {
46 curRoom
= gameRooms
[idx
];
48 blitType
= BlitType
.Green
;
49 curRoom
.willyDead
= true;
53 auto kst
= curRoom
.saveKeyState();
54 loadRoom(curRoom
.roomIdx
);
55 blitType
= BlitType
.Normal
;
56 curRoom
.willyDead
= false;
57 curRoom
.restoreKeyState(kst
);
61 auto gfxFill0
= buildImageMasked(gameData
["fill"][], 16, 24);
62 auto gfxFill1
= buildImageMasked(gameData
["fill"][384..$], 72, 24);
63 auto gfxAir
= buildImageMasked(gameData
["air"], 256, 8);
65 auto sdwin
= x11gfxInit("Manic Miner");
70 sdwin
.eventLoop(1000/20,
73 if (sdwin
.closed
) return;
76 if (!curRoom
.willyDead
&& !singleStepWait
) {
78 if (curRoom
.willyDead
) {
79 blitType
= BlitType
.BlackWhite
;
81 if (curRoom
.checkExit()) {
82 if (gameRooms
.length
-curRoom
.roomIdx
> 1) {
83 loadRoom(curRoom
.roomIdx
+1);
84 curRoom
.willyDead
= true;
86 blitType
= BlitType
.Green
;
89 singleStepWait
= singleStep
;
96 roomImg
= curRoom
.draw(roomImg
);
97 roomImg
.blitFast(0, 0);
99 gfxFill0
.blitFast(152, 40);
100 gfxFill1
.blitFast(176, 40);
101 printAt(154, 42, "Hello!", 13);
108 delegate (KeyEvent evt
) {
109 if (sdwin
.closed
) return;
111 case Key
.Left
: curRoom
.keyLeft
= evt
.pressed
; break;
112 case Key
.Right
: curRoom
.keyRight
= evt
.pressed
; break;
113 case Key
.Up
: curRoom
.keyUp
= evt
.pressed
; break;
114 case Key
.Down
: curRoom
.keyDown
= evt
.pressed
; break;
115 case Key
.Ctrl
: curRoom
.keyJump
= evt
.pressed
; break;
116 case Key
.N1
: debugColdet
= !debugColdet
; break;
118 if (!evt
.pressed
) break;
119 curRoom
.cheatRemoveKeys();
122 if (!evt
.pressed
) break;
123 debugColdet
= !debugColdet
;
126 if (!evt
.pressed
) break;
127 singleStep
= !singleStep
;
128 singleStepWait
= singleStep
;
131 if (!evt
.pressed
) break;
138 if (!evt
.pressed
) break;
139 if (inTitle
) goto case Key
.Space
;
140 if (curRoom
.willyDead
) { restartRoom(); break; }
141 if (singleStep
) { singleStepWait
= false; break; }
144 if (!evt
.pressed
) break;
145 blitType
= BlitType
.Normal
;
146 if (curRoom
.willyDead
) { restartRoom(); break; }
148 case Key
.Q
: case Key
.Escape
: doQuit
= true; break;
150 if (!evt
.pressed
) break;
151 if (curRoom
.roomIdx
> 0) {
152 loadRoom(curRoom
.roomIdx
-1);
156 if (!evt
.pressed
) break;
157 if (gameRooms
.length
-curRoom
.roomIdx
> 1) {
158 loadRoom(curRoom
.roomIdx
+1);
163 if (doQuit
) { sdwin
.close(); return; }
166 delegate (MouseEvent evt
) {
167 if (sdwin
.closed
) return;
170 delegate (dchar ch
) {
171 if (sdwin
.closed
) return;