switched to GPLv3 ONLY, because i don't trust FSF anymore
[knightmare.git] / zsprview.d
bloba17226fe0a029c1b54ebc63d4cfe574ccbab8ad7
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, version 3 of the License ONLY.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 module zsprview is aliced;
18 import arsd.simpledisplay;
19 import iv.vfs.io;
21 import zmythspr;
24 // ////////////////////////////////////////////////////////////////////////// //
25 MythSprite[] splist;
26 int spidx = 0;
29 // ////////////////////////////////////////////////////////////////////////// //
30 void paint (SimpleWindow w) {
31 auto painter = w.draw();
32 painter.outlineColor = Color.black;
33 painter.fillColor = Color(32, 32, 32);
34 painter.drawRectangle(Point(0, 0), w.width, w.height);
36 void putpix (int x, int y, Color c) {
37 painter.outlineColor = c;
38 painter.fillColor = c;
39 painter.drawRectangle(Point(x*4, y*4), 4, 4);
42 if (spidx < 0 || spidx >= splist.length) return;
43 auto spr = splist[spidx];
45 foreach (immutable dy; 0..spr.height) {
46 foreach (immutable dx; 0..spr.width) {
47 Color c = spr.getpix(dx, dy);
48 if (c.a) putpix(dx, dy, c);
51 writeln("spidx: ", spidx);
55 // ////////////////////////////////////////////////////////////////////////// //
56 void main () {
57 auto dataPathDriver = vfsNewDiskDriver("data");
58 vfsRegister!"first"(dataPathDriver);
59 try {
60 vfsAddPak("base.pak");
61 } catch (Exception e) {
64 //splist = loadSprites("data/DEVILS.SPR", true);
65 //splist = loadSprites("data/BULLET.SPR", true);
66 //splist = loadSprites("SPR16X16.SPR", true);
67 //splist = loadSprites("data/SPR16X24.SPR", true);
68 //splist = loadSprites("data/SHADOWS.SPR", true);
69 //splist = loadSprites("data/SPR8X8.SMB", false);
70 //splist = loadSprites("data/TILES.SMB", false);
71 //splist = loadSprites("data/ZST.SMB", false);
72 //splist = loadSprites("data/BACK1.SMB", false);
73 //splist = loadSprites("data/BACK2.SMB", false);
74 //splist = loadSprites("data/FSOFT.SPR", true);
75 splist = loadSprites("back1.smb", false);
76 auto sdwin = new SimpleWindow(800, 600, "SprView");
77 paint(sdwin);
78 sdwin.eventLoop(0,
79 delegate (KeyEvent ev) {
80 if (!ev.pressed) return;
81 if (ev == "Escape") sdwin.close();
82 if (ev == "Left" && spidx > 0) { --spidx; paint(sdwin); }
83 if (ev == "Right" && spidx < cast(int)splist.length-1) { ++spidx; paint(sdwin); }