Skip to content

Commit

Permalink
Interpolate angle for 2d map view
Browse files Browse the repository at this point in the history
  • Loading branch information
tmyqlfpir authored and Hendricks266 committed Aug 3, 2023
1 parent 0b68698 commit 4f46c25
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
8 changes: 4 additions & 4 deletions source/blood/src/map2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ void CViewMap::Draw(void)
viewResizeView(viewSize);
}

void CViewMap::Process(spritetype *pSprite)
void CViewMap::Process(int nX, int nY, short nAng)
{
nZoom = gZoom;
if (bFollowMode)
{
x = pSprite->x;
y = pSprite->y;
angle = pSprite->ang;
x = nX;
y = nY;
angle = nAng;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion source/blood/src/map2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CViewMap {
CViewMap();
void Init(int, int, int, short, char);
void Draw(void);
void Process(spritetype *pSprite);
void Process(int nX, int nY, short nAng);
void SetPos(int *, int*);
void FollowMode(char);
};
Expand Down
30 changes: 29 additions & 1 deletion source/blood/src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3899,7 +3899,35 @@ void viewDrawScreen(void)
}
if (gViewMode == 4)
{
gViewMap.Process(gView->pSprite);
int cX = 0, cY = 0, nAng = 0;
if (gViewMap.bFollowMode) // calculate get current player position for 2d map for follow mode
{
cX = gView->pSprite->x, cY = gView->pSprite->y, nAng = gView->pSprite->ang;
if (!VanillaMode()) // interpolate angle for 2d map view
{
fix16_t cA = gView->q16ang;
if (gViewInterpolate)
{
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0)
{
cX = interpolate(predictOld.at50, predict.at50, gInterpolate);
cY = interpolate(predictOld.at54, predict.at54, gInterpolate);
cA = interpolateangfix16(predictOld.at30, predict.at30, gInterpolate);
}
else
{
VIEW *pView = &gPrevView[gViewIndex];
cX = interpolate(pView->at50, cX, gInterpolate);
cY = interpolate(pView->at54, cY, gInterpolate);
cA = interpolateangfix16(pView->at30, cA, gInterpolate);
}
}
if (gView == gMe && (numplayers <= 1 || gPrediction) && gView->pXSprite->health != 0)
cA = gViewAngle;
nAng = fix16_to_int(cA);
}
}
gViewMap.Process(cX, cY, nAng);
}
viewDrawInterface(delta);
int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220;
Expand Down

0 comments on commit 4f46c25

Please sign in to comment.