- reimplemented player sprite display on Blood's automap.

This commit is contained in:
Christoph Oelckers 2020-09-06 21:15:59 +02:00
parent 18b39fd952
commit 9d39f770d4
4 changed files with 48 additions and 3 deletions

View file

@ -97,7 +97,7 @@ struct GameInterface : ::GameInterface
void NewGame(MapRecord *sng, int skill) override;
void NextLevel(MapRecord* map, int skill) override;
void LevelCompleted(MapRecord* map, int skill) override;
bool DrawAutomapPlayer(int x, int y, int z, int a) override;
GameStats getStats() override;
};

View file

@ -1053,7 +1053,50 @@ bool GameInterface::GenerateSavePic()
FString GameInterface::GetCoordString()
{
return "Player pos is unknown"; // todo: output at least something useful.
FString out;
out.Format("pos= %d, %d, %d - angle = %2.3f",
gMe->pSprite->x, gMe->pSprite->y, gMe->pSprite->z, gMe->pSprite->ang);
return out;
}
bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a)
{
int nCos = z * sintable[(0 - a) & 2047];
int nSin = z * sintable[(1536 - a) & 2047];
int nCos2 = mulscale16(nCos, yxaspect);
int nSin2 = mulscale16(nSin, yxaspect);
int nPSprite = gView->pSprite->index;
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
PLAYER* pPlayer = &gPlayer[i];
spritetype* pSprite = pPlayer->pSprite;
int px = pSprite->x - x;
int py = pSprite->y - y;
int pa = (pSprite->ang - a) & 2047;
int x1 = dmulscale16(px, nCos, -py, nSin);
int y1 = dmulscale16(py, nCos2, px, nSin2);
if (i == gView->nPlayer || gGameOptions.nGameType == 1)
{
int nTile = pSprite->picnum;
int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist << 2) + 16, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
int nTop, nBottom;
GetSpriteExtents(pSprite, &nTop, &nBottom);
int nScale = mulscale((pSprite->yrepeat + ((floorZ - nBottom) >> 8)) * z, yxaspect, 16);
nScale = ClipRange(nScale, 8000, 65536 << 1);
// Players on automap
double x = xdim / 2. + x1 / double(1 << 12);
double y = ydim / 2. + y1 / double(1 << 12);
// This very likely needs fixing later
DrawTexture(twod, tileGetTexture(nTile, true), x, y, DTA_ClipLeft, windowxy1.x, DTA_ClipTop, windowxy1.y, DTA_ScaleX, z/1536., DTA_ScaleY, z/1536., DTA_CenterOffset, true,
DTA_ClipRight, windowxy2.x + 1, DTA_ClipBottom, windowxy2.y + 1, DTA_Alpha, (pSprite->cstat & 2 ? 0.5 : 1.), TAG_DONE);
}
}
return true;
}

View file

@ -546,7 +546,8 @@ void DrawOverheadMap(int pl_x, int pl_y, int pl_angle)
drawredlines(x, y, gZoom, follow_a);
drawwhitelines(x, y, gZoom, follow_a);
DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle);
if (!gi->DrawAutomapPlayer(x, y, gZoom, follow_a))
DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle);
}

View file

@ -105,6 +105,7 @@ struct GameInterface
virtual void NextLevel(MapRecord* map, int skill) {}
virtual void NewGame(MapRecord* map, int skill) {}
virtual void LevelCompleted(MapRecord* map, int skill) {}
virtual bool DrawAutomapPlayer(int x, int y, int z, int a) { return false; }
virtual FString statFPS()
{