GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — NXEngine/map_system.cpp at master · EXL/NXEngine Expand file tree/ Copy pathmap_system.cppMore file actions 235 lines (183 loc) · 4.06 KB / Copy pathmap_system.cppFile metadata and controls235 lines (183 loc) · 4.06 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 // the Map System #include "nx.h" #include "map_system.h" #include "map_system.fdh" #define MS_EXPANDING 0 #define MS_DISPLAYED 1 #define MS_CONTRACTING 2 // # of frames in the expand/contract animation #define EXPAND_LENGTH 8 #define BANNER_TOP 7 #define BANNER_BTM 23 static struct { NXSurface *sfc; // surface for the map image int x, y; // the position of the upper-left corner of the image int w, h; // size of image int expandframe; // for expand/contract effect int current_row; // scan down effect int px, py; // the position of the you-are-here dot int timer; // for the flashing int state; // expanding, displayed, contracting int return_gm; // game mode to return to const char *bannertext; int textx, texty; bool lastbuttondown; } ms; bool ms_init(int return_to_mode) { memset(&ms, 0, sizeof(ms)); ms.return_gm = return_to_mode; ms.lastbuttondown = true; ms.w = map.xsize; ms.h = map.ysize; // create the surface ms.sfc = new NXSurface(ms.w, ms.h); ms.sfc->FillRect(0, 0, ms.w, ms.h, DK_BLUE); ms.x = (SCREEN_WIDTH / 2) - (ms.w / 2); ms.y = (SCREEN_HEIGHT / 2) - (ms.h / 2); // where will we put the dot? ms.px = ms.x + ((player->x >> CSF) / TILE_W); ms.py = ms.y + ((player->y >> CSF) / TILE_H); ms.bannertext = stages[game.curmap].stagename; ms.textx = (SCREEN_WIDTH / 2) - (GetFontWidth(ms.bannertext, 0) / 2); ms.texty = BANNER_TOP+3; return 0; } void ms_close(void) { memset(inputs, 0, sizeof(inputs)); delete ms.sfc; } /* void c------------------------------() {} */ void ms_tick(void) { DrawScene(); draw_banner(); if (ms.state == MS_EXPANDING) { ms.expandframe++; if (ms.expandframe > EXPAND_LENGTH) ms.state = MS_DISPLAYED; else draw_expand(); } if (ms.state == MS_DISPLAYED) { // scan down effect if (ms.current_row < map.ysize) { draw_row(ms.current_row++); if (ms.current_row < map.ysize) draw_row(ms.current_row++); } // draw map DrawRect(ms.x - 1, ms.y - 1, ms.x + ms.w, ms.y + ms.h, DK_BLUE); DrawSurface(ms.sfc, ms.x, ms.y); // you-are-here dot if (++ms.timer & 8) draw_sprite(ms.px, ms.py, SPR_MAP_PIXELS, 4); // dismissal if (ms.lastbuttondown) { if (!buttondown()) ms.lastbuttondown = false; } else if (buttondown()) { ms.state = MS_CONTRACTING; } } else if (ms.state == MS_CONTRACTING) { ms.expandframe--; if (ms.expandframe <= 0) { int param = (ms.return_gm == GM_INVENTORY) ? 1 : 0; game.setmode(ms.return_gm, param); } else { draw_expand(); } } } // expand/contract effect static void draw_expand(void) { int x1, y1, x2, y2; int wd = (map.xsize * ms.expandframe) / EXPAND_LENGTH; int ht = (map.ysize * ms.expandframe) / EXPAND_LENGTH; x1 = (SCREEN_WIDTH / 2) - (wd / 2); y1 = (SCREEN_HEIGHT / 2) - (ht / 2); x2 = (SCREEN_WIDTH / 2) + (wd / 2); y2 = (SCREEN_HEIGHT / 2) + (ht / 2); FillRect(x1, y1, x2, y2, DK_BLUE); } static void draw_banner(void) { FillRect(0, BANNER_TOP, SCREEN_WIDTH, BANNER_BTM, NXColor(0, 0, 0)); font_draw(ms.textx, ms.texty, ms.bannertext, 0); } /* void c------------------------------() {} */ // draw the specified row of map onto the spritesheet // the colors for the map system are not actually plotted as pixels, // but exist as 1x1 sprites on the TextBox spritesheet. static void draw_row(int y) { int x; Graphics::SetDrawTarget(ms.sfc); for(x=0;x<map.xsize;x++) { int tc = tilecode[map.tiles[x][y]]; draw_sprite(x, y, SPR_MAP_PIXELS, get_color(tc)); } Graphics::SetDrawTarget(screen); } static int get_color(int tilecode) { switch(tilecode) { case 0: return 0; case 0x01: case 0x02: case 0x40: case 0x44: case 0x51: case 0x52: case 0x55: case 0x56: case 0x60: case 0x71: case 0x72: case 0x75: case 0x76: case 0x80: case 0x81: case 0x82: case 0x83: case 0xA0: case 0xA1: case 0xA2: case 0xA3: return 1; case 0x43: case 0x50: case 0x53: case 0x54: case 0x57: case 0x63: case 0x70: case 0x73: case 0x74: case 0x77: return 2; default: return 3; } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |