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);
64 auto gfxSun
= buildImageMasked(gameData
["sun"], 24, 16);
65 auto gfxFinal
= buildImageMasked(gameData
["final"], 256, 64);
67 auto sdwin
= x11gfxInit("Manic Miner");
72 sdwin
.eventLoop(1000/20,
75 if (sdwin
.closed
) return;
78 if (!curRoom
.willyDead
&& !singleStepWait
) {
80 if (curRoom
.willyDead
) {
81 blitType
= BlitType
.BlackWhite
;
83 if (curRoom
.checkExit()) {
84 if (gameRooms
.length
-curRoom
.roomIdx
> 1) {
85 loadRoom(curRoom
.roomIdx
+1);
86 curRoom
.willyDead
= true;
88 blitType
= BlitType
.Green
;
91 singleStepWait
= singleStep
;
97 roomImg
= curRoom
.draw(roomImg
);
98 roomImg
.blitFast(0, 0);
112 for (int y
= sun
.h
-1; y
>= 0; --y
) {
113 for (int x
= 23; x
>= 0; --x
) {
114 ubyte data
= gameData
["sun"][(y
*24)+x
];
115 if (data
) setPixel8(60+x
, sun
.y
+y
, data
);
119 gfxFinal
.blitFast(0, 0);
120 //sunSpr.blitTo(img, 60, 32);
122 gfxFill0
.blitFast(152, 40);
123 gfxFill1
.blitFast(176, 40);
124 //printAt(154, 42, "Hello!", 13);
126 static int TITLEwf
= 2;
127 static int TITLEwp
= 0;
129 if (++TITLEwp
== 16) {
131 TITLEwf
= (TITLEwf
+2)&7;
133 drawWilly4(TITLEwf
+4);
141 delegate (KeyEvent evt
) {
142 if (sdwin
.closed
) return;
144 case Key
.Left
: curRoom
.keyLeft
= evt
.pressed
; break;
145 case Key
.Right
: curRoom
.keyRight
= evt
.pressed
; break;
146 case Key
.Up
: curRoom
.keyUp
= evt
.pressed
; break;
147 case Key
.Down
: curRoom
.keyDown
= evt
.pressed
; break;
148 case Key
.Ctrl
: curRoom
.keyJump
= evt
.pressed
; break;
149 case Key
.N1
: debugColdet
= !debugColdet
; break;
151 if (!evt
.pressed
) break;
152 curRoom
.cheatRemoveKeys();
155 if (!evt
.pressed
) break;
156 debugColdet
= !debugColdet
;
159 if (!evt
.pressed
) break;
160 singleStep
= !singleStep
;
161 singleStepWait
= singleStep
;
164 if (!evt
.pressed
) break;
171 if (!evt
.pressed
) break;
172 if (inTitle
) goto case Key
.Space
;
173 if (curRoom
.willyDead
) { restartRoom(); break; }
174 if (singleStep
) { singleStepWait
= false; break; }
177 if (!evt
.pressed
) break;
178 blitType
= BlitType
.Normal
;
179 if (curRoom
.willyDead
) { restartRoom(); break; }
181 case Key
.Q
: case Key
.Escape
: doQuit
= true; break;
183 if (!evt
.pressed
) break;
184 if (curRoom
.roomIdx
> 0) {
185 loadRoom(curRoom
.roomIdx
-1);
189 if (!evt
.pressed
) break;
190 if (gameRooms
.length
-curRoom
.roomIdx
> 1) {
191 loadRoom(curRoom
.roomIdx
+1);
196 if (doQuit
) { sdwin
.close(); return; }
199 delegate (MouseEvent evt
) {
200 if (sdwin
.closed
) return;
203 delegate (dchar ch
) {
204 if (sdwin
.closed
) return;