Side View
Half-Life 2 in eine 2D-Spiel zu verwandeln funktioniert ähnlich wie der Umbau auf den Third Person Modus und ist im Grunde nur eine Erweiterung davon. Deswegen ist es notwendig, dass du zuerst das Third Person-Tutorial durcharbeitest.
Inhaltsverzeichnis |
Anleitung
client\in_main.cpp
Suche nach
ConVar thirdperson_platformer( "thirdperson_platformer", "0", 0, "Player will aim in the direction they are moving." );
und ersetze es durch
ConVar thirdperson_platformer( "thirdperson_platformer", "1", FCVAR_CHEAT, "Player will aim in the direction they are moving." );
Suche die Funktion CInput::AdjustYaw und entferne dort zweimal
|| forward
Suche in der Funktion CInput::ComputeForwardMove nach
KeyState(&in_forward) || KeyState(&in_moveright) || KeyState(&in_back) || KeyState(&in_moveleft);
und ersetze es durch
KeyState(&in_moveright) || KeyState(&in_moveleft);
Füge in der selben Funktion unter
cmd->forwardmove += cl_forwardspeed.GetFloat() * movement;
folgendes ein
if ( cam_idealyaw.GetFloat() == 90.0 )
{
cmd->sidemove += cl_sidespeed.GetFloat() * KeyState (&in_forward);
cmd->sidemove -= cl_sidespeed.GetFloat() * KeyState (&in_back);
}
else if ( cam_idealyaw.GetFloat() == -90.0 )
{
cmd->sidemove += cl_sidespeed.GetFloat() * KeyState (&in_back);
cmd->sidemove -= cl_sidespeed.GetFloat() * KeyState (&in_forward);
}
Die beiden Werte in den Bedingungen können abweichen. Du musst einfach ausprobieren was passt.
client\in_camera.cpp
Suche in der Funktion CInput::CAM_Think nach
m_vecCameraOffset[ PITCH ] = camOffset[ PITCH ]; m_vecCameraOffset[ YAW ] = camOffset[ YAW ]; m_vecCameraOffset[ DIST ] = camOffset[ DIST ];
und füge darüber folgendes ein.
camOffset[ PITCH ] = 0; camOffset[ YAW ] = 90;
Der Wert von camOffset[ YAW ] kann in manchen Fällen auch "270" sein.
client\in_mouse.cpp
Such nach der Funktion CInput::ApplyMouse und ersetze sie durch folgendes
void CInput::ApplyMouse( QAngle& viewangles, CUserCmd *cmd, float mouse_x, float mouse_y )
{
viewangles[PITCH] += m_pitch->GetFloat() * mouse_y;
// Check pitch bounds
if (viewangles[PITCH] > cl_pitchdown.GetFloat())
{
viewangles[PITCH] = cl_pitchdown.GetFloat();
}
if (viewangles[PITCH] < -cl_pitchup.GetFloat())
{
viewangles[PITCH] = -cl_pitchup.GetFloat();
}
cmd->mousedx = (int)mouse_x;
cmd->mousedy = (int)mouse_y;
}
client\hud_crosshair.cpp
Füge über
using namespace vgui;
folgendes ein
extern ConVar cam_idealyaw;
Suche nach
m_pCrosshair->DrawSelf( x - 0.5f * m_pCrosshair->Width(), y - 0.5f * m_pCrosshair->Height(), m_clrCrosshair );
und ersetze es durch
// Calculate offset QAngle viewangles; engine->GetViewAngles( viewangles ); float yaw = cam_idealyaw.GetFloat(); float offset_x, offset_y; if ( yaw == -90) offset_x = cos(DEG2RAD(viewangles[PITCH])) * -200; else offset_x = cos(DEG2RAD(viewangles[PITCH])) * 200; offset_y = sin(DEG2RAD(viewangles[PITCH])) * 200; // Draw crosshair m_pCrosshair->DrawSelf( x - 0.5f * m_pCrosshair->Width() + offset_x, y - 0.5f * m_pCrosshair->Height() + offset_y, m_clrCrosshair );
client\hl2\hud_quickinfo.cpp
Füge am Anfang der Funktion CHUDQuickInfo::Paint folgendes ein
// Calculate offset QAngle viewangles; engine->GetViewAngles( viewangles ); float yaw = cam_idealyaw.GetFloat(); float offset_x, offset_y; if ( yaw == -90) offset_x = cos(DEG2RAD(viewangles[PITCH])) * -200; else offset_x = cos(DEG2RAD(viewangles[PITCH])) * 200; offset_y = sin(DEG2RAD(viewangles[PITCH])) * 200;
Suche nach
DrawWarning( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_healthFade );
und ersetze es durch
DrawWarning( xCenter - (m_icon_lb->Width() * 2) + offset_x, yCenter + offset_y, m_icon_lb, m_healthFade );
Suche nach
gHUD.DrawIconProgressBar( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_icon_lbe, ( 1.0f - healthPerc ), healthColor, CHud::HUDPB_VERTICAL );
und ersetze es durch
gHUD.DrawIconProgressBar( xCenter - (m_icon_lb->Width() * 2) + offset_x, yCenter + offset_y, m_icon_lb, m_icon_lbe, ( 1.0f - healthPerc ), healthColor, CHud::HUDPB_VERTICAL );
Suche nach
DrawWarning( xCenter + m_icon_rb->Width(), yCenter, m_icon_rb, m_ammoFade );
und ersetze es durch
DrawWarning( xCenter + m_icon_rb->Width() + offset_x, yCenter + offset_y, m_icon_rb, m_ammoFade );
Suche nach
gHUD.DrawIconProgressBar( xCenter + m_icon_rb->Width(), yCenter, m_icon_rb, m_icon_rbe, ammoPerc, ammoColor, CHud::HUDPB_VERTICAL );
und ersetze es durch
gHUD.DrawIconProgressBar( xCenter + m_icon_rb->Width() + offset_x, yCenter + offset_y, m_icon_rb, m_icon_rbe, ammoPerc, ammoColor, CHud::HUDPB_VERTICAL );