HUD drawing script
[dd2d.git] / data / scripts / d2dhud.dacs
blob4ac7d73c8ce89de7c9f2a49ba439b37bd61d22ad
1 /* DooM2D: Midnight on the Firing Line
2  * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3  * Understanding is not required. Only obedience.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 module d2dhud is "engine" "hud";
20 import apiActor;
21 import apiMap;
22 import apiMove;
23 import apiHud;
24 import stdlib;
26 import d2dplayer; // for some actor fields
29 const KeyFrameBase = 0;
32 // precache sprites
34 public void initializeAnim () {
35   animClearFrames("engine", "hud", "sleep");
36   // keys
37   animAddFrame("engine", "hud", "sleep", ACTOR_DIR_LEFT, "sprites/items/keyra0.vga");
38   animAddFrame("engine", "hud", "sleep", ACTOR_DIR_LEFT, "sprites/items/keyga0.vga");
39   animAddFrame("engine", "hud", "sleep", ACTOR_DIR_LEFT, "sprites/items/keyba0.vga");
44 public void drawHud () {
45   auto pl = getPlayerActor(1);
46   //writeln("pl.classname: ", pl.classname);
47   if (pl.dead || !pl.isPlayer) return;
48   // draw keys
49   // WARNING: keep in sync with INV_ITEM_KEY_xxx
50   //writeln("HUD");
51   auto inv = pl.invitems;
52   for (int kn = 0; kn < 3; ++kn) {
53     if (inv&(1<<kn)) {
54       string spn;
55       switch (kn) {
56         case 0: spn = "sprites/items/keyra0.vga"; break;
57         case 1: spn = "sprites/items/keyga0.vga"; break;
58         case 2: spn = "sprites/items/keyba0.vga"; break;
59         default: continue; // just in case
60       }
61       drawSpriteAt(spn, 4+kn*(spriteWidth(spn)+1), viewportHeight/*-spriteHeight(spn)*/-4);
62     }
63   }
64   /*
65   {
66     string spn = "sprites/items/keyra0.vga";
67     drawSpriteAt(spn, 4, viewportHeight-4);
68   }
69   */