📄 am_map.c
字号:
/* Is this an X-major or Y-major line? */ if (DeltaY > DeltaX) { /* Y-major line; calculate 16-bit fixed-point fractional part of a pixel that X advances each time Y advances 1 pixel, truncating the result so that we won't overrun the endpoint along the X axis */ ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; /* Draw all pixels other than the first and last */ while (--DeltaY) { ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ ErrorAcc += ErrorAdj; /* calculate error for next pixel */ if (ErrorAcc <= ErrorAccTemp) { /* The error accumulator turned over, so advance the X coord */ X0 += XDir; } Y0++; /* Y-major, so always advance Y */ /* The IntensityBits most significant bits of ErrorAcc give us the intensity weighting for this pixel, and the complement of the weighting for the paired pixel */ Weighting = ErrorAcc >> IntensityShift; PUTDOT(X0, Y0, &BaseColor[Weighting], &BaseColor[7]); PUTDOT(X0 + XDir, Y0, &BaseColor[(Weighting ^ WeightingComplementMask)], &BaseColor[7]); } /* Draw the final pixel, which is always exactly intersected by the line and so needs no weighting */ PUTDOT(X1, Y1, &BaseColor[0], NULL); return; } /* It's an X-major line; calculate 16-bit fixed-point fractional part of a pixel that Y advances each time X advances 1 pixel, truncating the result to avoid overrunning the endpoint along the X axis */ ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; /* Draw all pixels other than the first and last */ while (--DeltaX) { ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ ErrorAcc += ErrorAdj; /* calculate error for next pixel */ if (ErrorAcc <= ErrorAccTemp) { /* The error accumulator turned over, so advance the Y coord */ Y0++; } X0 += XDir; /* X-major, so always advance X */ /* The IntensityBits most significant bits of ErrorAcc give us the intensity weighting for this pixel, and the complement of the weighting for the paired pixel */ Weighting = ErrorAcc >> IntensityShift; PUTDOT(X0, Y0, &BaseColor[Weighting], &BaseColor[7]); PUTDOT(X0, Y0 + 1, &BaseColor[(Weighting ^ WeightingComplementMask)], &BaseColor[7]); } /* Draw the final pixel, which is always exactly intersected by the line and so needs no weighting */ PUTDOT(X1, Y1, &BaseColor[0], NULL);}void AM_drawMline(mline_t *ml, int color){ static fline_t fl; if (AM_clipMline(ml, &fl)) AM_drawFline(&fl, color); // draws it on frame buffer using fb coords}void AM_drawGrid(int color){ fixed_t x, y; fixed_t start, end; mline_t ml; // Figure out start of vertical gridlines start = m_x; if ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)); end = m_x + m_w; // draw vertical gridlines ml.a.y = m_y; ml.b.y = m_y+m_h; for (x=start; x<end; x+=(MAPBLOCKUNITS<<FRACBITS)) { ml.a.x = x; ml.b.x = x; AM_drawMline(&ml, color); } // Figure out start of horizontal gridlines start = m_y; if ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)); end = m_y + m_h; // draw horizontal gridlines ml.a.x = m_x; ml.b.x = m_x + m_w; for (y=start; y<end; y+=(MAPBLOCKUNITS<<FRACBITS)) { ml.a.y = y; ml.b.y = y; AM_drawMline(&ml, color); }}void AM_drawWalls(void){ int i; static mline_t l; for (i=0;i<numlines;i++) { l.a.x = lines[i].v1->x; l.a.y = lines[i].v1->y; l.b.x = lines[i].v2->x; l.b.y = lines[i].v2->y; if (cheating || (lines[i].flags & ML_MAPPED)) { if ((lines[i].flags & LINE_NEVERSEE) && !cheating) continue; if (!lines[i].backsector) { AM_drawMline(&l, WALLCOLORS+lightlev); } else { if (lines[i].flags & ML_SECRET) // secret door { if (cheating) AM_drawMline(&l, 0); else AM_drawMline(&l, WALLCOLORS+lightlev); } else if(lines[i].special == 13 || lines[i].special == 83) { // Locked door line -- all locked doors are greed AM_drawMline(&l, GREENKEY); } else if(lines[i].special == 70 || lines[i].special == 71) { // intra-level teleports are blue AM_drawMline(&l, BLUEKEY); } else if(lines[i].special == 74 || lines[i].special == 75) { // inter-level teleport/game-winning exit -- both are red AM_drawMline(&l, BLOODRED); } else if (lines[i].backsector->floorheight != lines[i].frontsector->floorheight) { AM_drawMline(&l, FDWALLCOLORS + lightlev); // floor level change } else if (lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight) { AM_drawMline(&l, CDWALLCOLORS+lightlev); // ceiling level change } else if (cheating) { AM_drawMline(&l, TSWALLCOLORS+lightlev); } } } else if (plr->powers[pw_allmap]) { if (!(lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS+3); } }}void AM_rotate(fixed_t *x, fixed_t *y, angle_t a){ fixed_t tmpx; tmpx = FixedMul(*x,finecosine[a>>ANGLETOFINESHIFT]) - FixedMul(*y,finesine[a>>ANGLETOFINESHIFT]); *y = FixedMul(*x,finesine[a>>ANGLETOFINESHIFT]) + FixedMul(*y,finecosine[a>>ANGLETOFINESHIFT]); *x = tmpx;}void AM_drawLineCharacter(mline_t *lineguy, int lineguylines, fixed_t scale, angle_t angle, int color, fixed_t x, fixed_t y){ int i; mline_t l; for (i=0;i<lineguylines;i++) { l.a.x = lineguy[i].a.x; l.a.y = lineguy[i].a.y; if (scale) { l.a.x = FixedMul(scale, l.a.x); l.a.y = FixedMul(scale, l.a.y); } if (angle) AM_rotate(&l.a.x, &l.a.y, angle); l.a.x += x; l.a.y += y; l.b.x = lineguy[i].b.x; l.b.y = lineguy[i].b.y; if (scale) { l.b.x = FixedMul(scale, l.b.x); l.b.y = FixedMul(scale, l.b.y); } if (angle) AM_rotate(&l.b.x, &l.b.y, angle); l.b.x += x; l.b.y += y; AM_drawMline(&l, color); }}void AM_drawPlayers(void){ int i; player_t *p; static int their_colors[] = { AM_PLR1_COLOR, AM_PLR2_COLOR, AM_PLR3_COLOR, AM_PLR4_COLOR, AM_PLR5_COLOR, AM_PLR6_COLOR, AM_PLR7_COLOR, AM_PLR8_COLOR }; int their_color = -1; int color; if(!netgame) { AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); return; } for(i = 0; i < MAXPLAYERS; i++) { their_color++; p = &players[i]; if(deathmatch && !singledemo && p != plr) { continue; } if (!playeringame[i]) continue; color = their_colors[their_color]; AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y); }}void AM_drawThings(int colors, int colorrange){ int i; mobj_t *t; for (i=0;i<numsectors;i++) { t = sectors[i].thinglist; while (t) { AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<<FRACBITS, t->angle, colors+lightlev, t->x, t->y); t = t->snext; } }}/*void AM_drawMarks(void){ int i, fx, fy, w, h; for (i=0;i<AM_NUMMARKPOINTS;i++) { if (markpoints[i].x != -1) { w = SHORT(marknums[i]->width); h = SHORT(marknums[i]->height); fx = CXMTOF(markpoints[i].x); fy = CYMTOF(markpoints[i].y); if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) V_DrawPatch(fx, fy, marknums[i]); } }}*//*void AM_drawkeys(void){ if(KeyPoints[0].x != 0 || KeyPoints[0].y != 0) { AM_drawLineCharacter(keysquare, NUMKEYSQUARELINES, 0, 0, YELLOWKEY, KeyPoints[0].x, KeyPoints[0].y); } if(KeyPoints[1].x != 0 || KeyPoints[1].y != 0) { AM_drawLineCharacter(keysquare, NUMKEYSQUARELINES, 0, 0, GREENKEY, KeyPoints[1].x, KeyPoints[1].y); } if(KeyPoints[2].x != 0 || KeyPoints[2].y != 0) { AM_drawLineCharacter(keysquare, NUMKEYSQUARELINES, 0, 0, BLUEKEY, KeyPoints[2].x, KeyPoints[2].y); }}*//*void AM_drawCrosshair(int color){ fb[(f_w*(f_h+1))/2] = color; // single point for now}*/void AM_Drawer (void){ if (!automapactive) return; UpdateState |= I_FULLSCRN; AM_clearFB(BACKGROUND); if (grid) AM_drawGrid(GRIDCOLORS); AM_drawWalls(); AM_drawPlayers(); DrawWorldTimer(); if (cheating==2) AM_drawThings(THINGCOLORS, THINGRANGE);// AM_drawCrosshair(XHAIRCOLORS);// AM_drawMarks();// if(gameskill == sk_baby) AM_drawkeys(); MN_DrTextA(P_GetMapName(gamemap), 38, 144); if(ShowKills && netgame && deathmatch) { AM_DrawDeathmatchStats(); }// I_Update();// V_MarkRect(f_x, f_y, f_w, f_h);}//===========================================================================//// AM_DrawDeathmatchStats////===========================================================================// 8-player note: Proper player color names here, toochar *PlayerColorText[MAXPLAYERS] ={ "BLUE:", "RED:", "YELLOW:", "GREEN:", "JADE:", "WHITE:", "HAZEL:", "PURPLE:"};void AM_DrawDeathmatchStats(void){ int i, j, k, m; int fragCount[MAXPLAYERS]; int order[MAXPLAYERS]; char textBuffer[80]; int yPosition; for(i = 0; i < MAXPLAYERS; i++) { fragCount[i] = 0; order[i] = -1; } for(i = 0; i < MAXPLAYERS; i++) { if(!playeringame[i]) { continue; } else { for(j = 0; j < MAXPLAYERS; j++) { if(playeringame[j]) { fragCount[i] += players[i].frags[j]; } } for(k = 0; k < MAXPLAYERS; k++) { if(order[k] == -1) { order[k] = i; break; } else if(fragCount[i] > fragCount[order[k]]) { for(m = MAXPLAYERS-1; m > k; m--) { order[m] = order[m-1]; } order[k] = i; break; } } } } yPosition = 15; for(i = 0; i < MAXPLAYERS; i++) { if(!playeringame[order[i]]) { continue; } else { MN_DrTextA(PlayerColorText[order[i]], 8, yPosition); sprintf(textBuffer, "%d", fragCount[order[i]]); MN_DrTextA(textBuffer, 80, yPosition); yPosition += 10; } }}//===========================================================================//// DrawWorldTimer////===========================================================================static void DrawWorldTimer(void){ int days; int hours; int minutes; int seconds; int worldTimer; char timeBuffer[15]; char dayBuffer[20]; worldTimer = players[consoleplayer].worldTimer; worldTimer /= 35; days = worldTimer/86400; worldTimer -= days*86400; hours = worldTimer/3600; worldTimer -= hours*3600; minutes = worldTimer/60; worldTimer -= minutes*60; seconds = worldTimer; sprintf(timeBuffer, "%.2d : %.2d : %.2d", hours, minutes,seconds); MN_DrTextA(timeBuffer, 240, 8); if (days) { if (days==1) { sprintf(dayBuffer, "%.2d DAY", days); } else { sprintf(dayBuffer, "%.2d DAYS", days); } MN_DrTextA(dayBuffer, 240, 20); if (days >= 5) { MN_DrTextA("YOU FREAK!!!", 230, 35); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -