Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blood: Interpolate angle for 2d map view #735

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/blood/src/gamemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ void CGameMenuItemZEdit::Draw(void)
bool CGameMenuItemZEdit::Event(CGameMenuEvent &event)
{
static char buffer[256];
static CGameMenuItemZEdit *pGameMenuItemZEdit = NULL;
// Hack
if (event.at2 == sc_kpad_2 || event.at2 == sc_kpad_4 || event.at2 == sc_kpad_6 || event.at2 == sc_kpad_8)
event.at0 = kMenuEventKey;
Expand All @@ -1917,6 +1918,7 @@ bool CGameMenuItemZEdit::Event(CGameMenuEvent &event)
strncpy(at20, buffer, at24);
at20[at24-1] = 0;
at30 = 0;
pGameMenuItemZEdit = NULL;
return false;
}
return true;
Expand All @@ -1934,6 +1936,13 @@ bool CGameMenuItemZEdit::Event(CGameMenuEvent &event)
at30 = 0;
return false;
}
else // unselect previously edited item
{
if (!pGameMenuItemZEdit)
pGameMenuItemZEdit = this;
else if (pGameMenuItemZEdit != this)
pGameMenuItemZEdit->at30 = 0, pGameMenuItemZEdit = this;
}
strncpy(buffer, at20, at24);
buffer[at24-1] = 0;
at30 = 1;
Expand Down
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