mirror of
https://github.com/rlabrecque/SteamworksSDK.git
synced 2026-10-10 09:33:04 +08:00
v1.32
This commit is contained in:
@@ -108,10 +108,14 @@ public:
|
||||
virtual bool BFlushPointBuffer() = 0;
|
||||
|
||||
// Draw a filled quad
|
||||
virtual bool BDrawFilledQuad( float xPos0, float yPos0, float xPos1, float yPos1, DWORD dwColor ) = 0;
|
||||
virtual bool BDrawFilledRect( float xPos0, float yPos0, float xPos1, float yPos1, DWORD dwColor ) = 0;
|
||||
|
||||
// Draw a textured rectangle
|
||||
virtual bool BDrawTexturedQuad( float xPos0, float yPos0, float xPos1, float yPos1,
|
||||
virtual bool BDrawTexturedRect( float xPos0, float yPos0, float xPos1, float yPos1,
|
||||
float u0, float v0, float u1, float v1, DWORD dwColor, HGAMETEXTURE hTexture ) = 0;
|
||||
|
||||
// Draw a textured arbitrary quad
|
||||
virtual bool BDrawTexturedQuad( float xPos0, float yPos0, float xPos1, float yPos1, float xPos2, float yPos2, float xPos3, float yPos3,
|
||||
float u0, float v0, float u1, float v1, DWORD dwColor, HGAMETEXTURE hTexture ) = 0;
|
||||
|
||||
// Flush any still cached quad buffers
|
||||
|
||||
@@ -205,13 +205,6 @@ static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow )
|
||||
// set our debug handler
|
||||
SteamClient()->SetWarningMessageHook( &SteamAPIDebugTextHook );
|
||||
|
||||
// Tell Steam where it's overlay should show notification dialogs, this can be top right, top left,
|
||||
// bottom right, bottom left. The default position is the bottom left if you don't call this.
|
||||
// Generally you should use the default and not call this as users will be most comfortable with
|
||||
// the default position. The API is provided in case the bottom right creates a serious conflict
|
||||
// with important UI in your game.
|
||||
SteamUtils()->SetOverlayNotificationPosition( k_EPositionTopRight );
|
||||
|
||||
// Ensure that the user has logged into Steam. This will always return true if the game is launched
|
||||
// from Steam, but if Steam is at the login prompt when you run your game from the debugger, it
|
||||
// will return false.
|
||||
@@ -323,7 +316,7 @@ int main(int argc, const char **argv)
|
||||
{
|
||||
char szCmdLine[1024];
|
||||
char *pszStart = szCmdLine;
|
||||
char * const pszEnd = szCmdLine + Q_ARRAYSIZE(szCmdLine);
|
||||
char * const pszEnd = szCmdLine + V_ARRAYSIZE(szCmdLine);
|
||||
|
||||
*szCmdLine = '\0';
|
||||
|
||||
@@ -342,7 +335,7 @@ int main(int argc, const char **argv)
|
||||
*pszStart++ = ' ';
|
||||
}
|
||||
|
||||
szCmdLine[Q_ARRAYSIZE(szCmdLine) - 1] = '\0';
|
||||
szCmdLine[V_ARRAYSIZE(szCmdLine) - 1] = '\0';
|
||||
|
||||
return RealMain( szCmdLine, 0, 0 );
|
||||
}
|
||||
@@ -352,7 +345,7 @@ int main(int argc, const char **argv)
|
||||
{
|
||||
char szCmdLine[1024];
|
||||
char *pszStart = szCmdLine;
|
||||
char * const pszEnd = szCmdLine + Q_ARRAYSIZE(szCmdLine);
|
||||
char * const pszEnd = szCmdLine + V_ARRAYSIZE(szCmdLine);
|
||||
*szCmdLine = '\0';
|
||||
for ( int i = 1; i < argc; i++ )
|
||||
{
|
||||
@@ -366,7 +359,7 @@ int main(int argc, const char **argv)
|
||||
if ( i < argc-1 )
|
||||
*pszStart++ = ' ';
|
||||
}
|
||||
szCmdLine[Q_ARRAYSIZE(szCmdLine) - 1] = '\0';
|
||||
szCmdLine[V_ARRAYSIZE(szCmdLine) - 1] = '\0';
|
||||
return RealMain( szCmdLine, 0, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,7 @@ CMainMenu::CMainMenu( IGameEngine *pGameEngine ) : CBaseMenu<EClientGameState>(
|
||||
AddMenuItem( MenuItem_t( "Instructions", k_EClientGameInstructions ) );
|
||||
AddMenuItem( MenuItem_t( "Stats and Achievements", k_EClientStatsAchievements ) );
|
||||
AddMenuItem( MenuItem_t( "Leaderboards", k_EClientLeaderboards ) );
|
||||
AddMenuItem( MenuItem_t( "Friends List", k_EClientFriendsList ) );
|
||||
AddMenuItem( MenuItem_t( "Group chat room", k_EClientClanChatRoom ) );
|
||||
AddMenuItem( MenuItem_t( "Remote Storage", k_EClientRemoteStorage ) );
|
||||
AddMenuItem( MenuItem_t( "Write Minidump", k_EClientMinidump ) );
|
||||
|
||||
+236
-17
@@ -6,10 +6,12 @@
|
||||
//=============================================================================
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GameEngine.h"
|
||||
#include "Ship.h"
|
||||
#include "stdlib.h"
|
||||
#include "SpaceWarServer.h"
|
||||
#include "StatsAndAchievements.h"
|
||||
#include "Inventory.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -134,6 +136,7 @@ CShip::CShip( IGameEngine *pGameEngine, bool bIsServerInstance, float xPos, floa
|
||||
m_ulLastThrustStartedTickCount = 0;
|
||||
m_dwVKLeft = 0;
|
||||
m_dwVKRight = 0;
|
||||
m_nFade = 255;
|
||||
m_dwVKForwardThrusters = 0;
|
||||
m_dwVKReverseThrusters = 0;
|
||||
m_dwVKFire = 0;
|
||||
@@ -144,6 +147,11 @@ CShip::CShip( IGameEngine *pGameEngine, bool bIsServerInstance, float xPos, floa
|
||||
m_bIsLocalPlayer = false;
|
||||
m_ulLastClientUpdateTick = 0;
|
||||
m_bIsServerInstance = bIsServerInstance;
|
||||
m_nShipDecoration = 0;
|
||||
m_nShipPower = 0;
|
||||
m_nShipWeapon = 0;
|
||||
m_hTextureWhite = 0;
|
||||
m_nShipShieldStrength = 0;
|
||||
|
||||
memset( &m_SpaceWarClientUpdateData, 0, sizeof( m_SpaceWarClientUpdateData ) );
|
||||
|
||||
@@ -152,14 +160,46 @@ CShip::CShip( IGameEngine *pGameEngine, bool bIsServerInstance, float xPos, floa
|
||||
m_rgPhotonBeams[i] = NULL;
|
||||
}
|
||||
|
||||
// Initialize our geometry
|
||||
AddLine( -9.0f, 12.0f, 0.0f, -12.0f, dwShipColor );
|
||||
AddLine( 0.0f, -12.0f, 9.0f, 12.0f, dwShipColor );
|
||||
AddLine( 9.0f, 12.0f, -9.0f, 12.0f, dwShipColor );
|
||||
BuildGeometry();
|
||||
|
||||
SetPosition( xPos, yPos );
|
||||
}
|
||||
#pragma warning( pop )
|
||||
|
||||
void CShip::BuildGeometry()
|
||||
{
|
||||
ClearVertexes();
|
||||
|
||||
// Initialize our geometry
|
||||
AddLine( -9.0f, 12.0f, 0.0f, -12.0f, m_dwShipColor );
|
||||
AddLine( 0.0f, -12.0f, 9.0f, 12.0f, m_dwShipColor );
|
||||
AddLine( 9.0f, 12.0f, -9.0f, 12.0f, m_dwShipColor );
|
||||
|
||||
switch ( m_nShipDecoration )
|
||||
{
|
||||
case 1:
|
||||
AddLine( 0.0f, -12.0f, -0.0f, 12.0f, m_dwShipColor );
|
||||
AddLine( 4.5f, 0.0f, -4.5f, 0.0f, m_dwShipColor );
|
||||
break;
|
||||
case 2:
|
||||
AddLine( 0.0f, -12.0f, -0.0f, 12.0f, m_dwShipColor );
|
||||
AddLine( 4.5f, 0.0f, -4.5f, 0.0f, m_dwShipColor );
|
||||
AddLine( 2.5f, -6.0f, -9.0f, 12.0f, m_dwShipColor );
|
||||
AddLine( 9.0f, 12.0f, -2.5f, -6.0f, m_dwShipColor );
|
||||
break;
|
||||
case 3:
|
||||
AddLine( 0.0f, -12.0f, 0.0f, 12.0f, m_dwShipColor );
|
||||
AddLine( 2.0f, -8.0f, 2.0f, 12.0f, m_dwShipColor );
|
||||
AddLine( -2.0f, -8.0f, -2.0f, 12.0f, m_dwShipColor );
|
||||
break;
|
||||
case 4:
|
||||
AddLine( -12.0, 12.0f, -3.0f,-12.0f, m_dwShipColor );
|
||||
AddLine( -17.0f, 4.0f,-11.0f,-10.0f, m_dwShipColor );
|
||||
AddLine( -17.0f, 4.0f,-10.0f, 7.0f, m_dwShipColor );
|
||||
AddLine( -11.0f,-10.0f, -3.0f,-7.0f, m_dwShipColor );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
@@ -205,6 +245,17 @@ void CShip::OnReceiveServerUpdate( ServerShipUpdateData_t *pUpdateData )
|
||||
SetVelocity( pUpdateData->GetXVelocity(), pUpdateData->GetYVelocity() );
|
||||
SetAccumulatedRotation( pUpdateData->GetRotation() );
|
||||
|
||||
m_nShipPower = pUpdateData->GetPower();
|
||||
m_nShipWeapon = pUpdateData->GetWeapon();
|
||||
if ( m_nShipDecoration != pUpdateData->GetDecoration() )
|
||||
{
|
||||
m_nShipDecoration = pUpdateData->GetDecoration();
|
||||
BuildGeometry();
|
||||
}
|
||||
if ( !m_bIsLocalPlayer || pUpdateData->GetShieldStrength() == 0 )
|
||||
{
|
||||
m_nShipShieldStrength = pUpdateData->GetShieldStrength();
|
||||
}
|
||||
|
||||
m_bForwardThrustersActive = pUpdateData->GetForwardThrustersActive();
|
||||
m_bReverseThrustersActive = pUpdateData->GetReverseThrustersActive();
|
||||
@@ -249,6 +300,12 @@ void CShip::OnReceiveClientUpdate( ClientSpaceWarUpdateData_t *pUpdateData )
|
||||
OutputDebugString( "Should not be receiving client updates on non-server instances\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
m_nShipDecoration = pUpdateData->GetDecoration();
|
||||
m_nShipPower = pUpdateData->GetPower();
|
||||
m_nShipWeapon = pUpdateData->GetWeapon();
|
||||
m_nShipShieldStrength = pUpdateData->GetShieldStrength();
|
||||
|
||||
memcpy( &m_SpaceWarClientUpdateData, pUpdateData, sizeof( ClientSpaceWarUpdateData_t ) );
|
||||
}
|
||||
|
||||
@@ -268,6 +325,10 @@ bool CShip::BGetClientUpdateData( ClientSpaceWarUpdateData_t *pUpdateData )
|
||||
if ( m_bIsLocalPlayer )
|
||||
{
|
||||
m_SpaceWarClientUpdateData.SetPlayerName( SteamFriends()->GetFriendPersonaName( SteamUser()->GetSteamID() ) );
|
||||
m_SpaceWarClientUpdateData.SetDecoration( m_nShipDecoration );
|
||||
m_SpaceWarClientUpdateData.SetWeapon( m_nShipWeapon );
|
||||
m_SpaceWarClientUpdateData.SetPower( m_nShipPower );
|
||||
m_SpaceWarClientUpdateData.SetShieldStrength( m_nShipShieldStrength );
|
||||
}
|
||||
|
||||
memcpy( pUpdateData, &m_SpaceWarClientUpdateData, sizeof( ClientSpaceWarUpdateData_t ) );
|
||||
@@ -374,6 +435,52 @@ void CShip::RunFrame()
|
||||
m_SpaceWarClientUpdateData.SetForwardThrustersPressed( true );
|
||||
}
|
||||
}
|
||||
|
||||
// Hardcoded keys to choose various outfits and weapon powerups which require inventory. Note that this is not
|
||||
// a "secure" multiplayer model - clients can lie about what they own. A more robust solution, if your items
|
||||
// matter enough to bother, would be to use SerializeResult / DeserializeResult to encode the fact that your
|
||||
// steamid owns certain items, and then send that encoded result to the server which decodes and verifies it.
|
||||
if ( m_pGameEngine->BIsKeyDown( 0x30 ) )
|
||||
{
|
||||
m_nShipDecoration = 0;
|
||||
BuildGeometry();
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x31 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipDecoration1 ) )
|
||||
{
|
||||
m_nShipDecoration = 1;
|
||||
BuildGeometry();
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x32 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipDecoration2 ) )
|
||||
{
|
||||
m_nShipDecoration = 2;
|
||||
BuildGeometry();
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x33 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipDecoration3 ) )
|
||||
{
|
||||
m_nShipDecoration = 3;
|
||||
BuildGeometry();
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x34 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipDecoration4 ) )
|
||||
{
|
||||
m_nShipDecoration = 4;
|
||||
BuildGeometry();
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x35 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipWeapon1 ) )
|
||||
{
|
||||
m_nShipWeapon = 1;
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x36 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipWeapon2 ) )
|
||||
{
|
||||
m_nShipWeapon = 2;
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x37 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipSpecial1 ) )
|
||||
{
|
||||
m_nShipPower = 1;
|
||||
}
|
||||
else if ( m_pGameEngine->BIsKeyDown( 0x38 ) && SpaceWarLocalInventory()->HasInstanceOf( k_SpaceWarItem_ShipSpecial2 ) )
|
||||
{
|
||||
m_nShipPower = 2;
|
||||
}
|
||||
}
|
||||
else if ( m_bIsServerInstance )
|
||||
{
|
||||
@@ -433,14 +540,57 @@ void CShip::RunFrame()
|
||||
{
|
||||
m_ulLastPhotonTickCount = ulCurrentTickCount;
|
||||
|
||||
float xVelocity = GetXVelocity() + ( sinvalue * 275 );
|
||||
float yVelocity = GetYVelocity() - ( cosvalue * 275 );
|
||||
if ( m_nShipWeapon == 1 ) // Item#101
|
||||
{
|
||||
float sinvalue1 = (float)sin( GetAccumulatedRotation() - .1f );
|
||||
float cosvalue1 = (float)cos( GetAccumulatedRotation() - .1f );
|
||||
float sinvalue2 = (float)sin( GetAccumulatedRotation() + .1f );
|
||||
float cosvalue2 = (float)cos( GetAccumulatedRotation() + .1f );
|
||||
|
||||
// Offset 12 points up from the center of the ship, compensating for rotation
|
||||
float xPos = GetXPos() - sinvalue*-12.0f;
|
||||
float yPos = GetYPos() + cosvalue*-12.0f;
|
||||
float xVelocity = GetXVelocity() + ( sinvalue1 * 275 );
|
||||
float yVelocity = GetYVelocity() - ( cosvalue1 * 275 );
|
||||
|
||||
m_rgPhotonBeams[nNextAvailablePhotonBeamSlot] = new CPhotonBeam( m_pGameEngine, xPos, yPos, m_dwShipColor, GetAccumulatedRotation(), xVelocity, yVelocity );
|
||||
// Offset 12 points up from the center of the ship, compensating for rotation
|
||||
float xPos = GetXPos() - sinvalue1*-12.0f;
|
||||
float yPos = GetYPos() + cosvalue1*-12.0f;
|
||||
|
||||
m_rgPhotonBeams[nNextAvailablePhotonBeamSlot] = new CPhotonBeam( m_pGameEngine, xPos, yPos, m_dwShipColor, GetAccumulatedRotation(), xVelocity, yVelocity );
|
||||
|
||||
nNextAvailablePhotonBeamSlot = -1; // Track next available slot for use spawning new beams below
|
||||
for( int i=0; i < MAX_PHOTON_BEAMS_PER_SHIP; ++i )
|
||||
{
|
||||
if ( !m_rgPhotonBeams[i] && nNextAvailablePhotonBeamSlot == -1 )
|
||||
nNextAvailablePhotonBeamSlot = i;
|
||||
}
|
||||
|
||||
if ( nNextAvailablePhotonBeamSlot != -1 )
|
||||
{
|
||||
xVelocity = GetXVelocity() + ( sinvalue2 * 275 );
|
||||
yVelocity = GetYVelocity() - ( cosvalue2 * 275 );
|
||||
|
||||
// Offset 12 points up from the center of the ship, compensating for rotation
|
||||
xPos = GetXPos() - sinvalue2*-12.0f;
|
||||
yPos = GetYPos() + cosvalue2*-12.0f;
|
||||
|
||||
m_rgPhotonBeams[nNextAvailablePhotonBeamSlot] = new CPhotonBeam( m_pGameEngine, xPos, yPos, m_dwShipColor, GetAccumulatedRotation(), xVelocity, yVelocity );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float speed = 275;
|
||||
if ( m_nShipWeapon == 2 ) // Item#102
|
||||
{
|
||||
speed = 500;
|
||||
}
|
||||
float xVelocity = GetXVelocity() + ( sinvalue * speed );
|
||||
float yVelocity = GetYVelocity() - ( cosvalue * speed );
|
||||
|
||||
// Offset 12 points up from the center of the ship, compensating for rotation
|
||||
float xPos = GetXPos() - sinvalue*-12.0f;
|
||||
float yPos = GetYPos() + cosvalue*-12.0f;
|
||||
|
||||
m_rgPhotonBeams[nNextAvailablePhotonBeamSlot] = new CPhotonBeam( m_pGameEngine, xPos, yPos, m_dwShipColor, GetAccumulatedRotation(), xVelocity, yVelocity );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,40 +607,105 @@ void CShip::RunFrame()
|
||||
//-----------------------------------------------------------------------------
|
||||
void CShip::Render()
|
||||
{
|
||||
int beamCount = 0;
|
||||
|
||||
if ( m_bDisabled )
|
||||
return;
|
||||
|
||||
// render all the photon beams we have outstanding
|
||||
for( int i=0; i < MAX_PHOTON_BEAMS_PER_SHIP; ++i )
|
||||
for ( int i = 0; i < MAX_PHOTON_BEAMS_PER_SHIP; ++i )
|
||||
{
|
||||
if ( m_rgPhotonBeams[i] )
|
||||
{
|
||||
m_rgPhotonBeams[i]->Render();
|
||||
beamCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( m_bExploding )
|
||||
if ( m_bExploding )
|
||||
{
|
||||
// Don't draw actual ship, instead draw the pieces created in the explosion
|
||||
std::list<CShipDebris *>::iterator iter;
|
||||
for( iter = m_ListDebris.begin(); iter != m_ListDebris.end(); ++iter )
|
||||
(*iter)->Render();
|
||||
for ( iter = m_ListDebris.begin(); iter != m_ListDebris.end(); ++iter )
|
||||
( *iter )->Render();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we should be drawing thrusters
|
||||
if ( m_bForwardThrustersActive )
|
||||
{
|
||||
if ( rand()%3 == 0 )
|
||||
if ( rand() % 3 == 0 )
|
||||
m_ForwardThrusters.Render();
|
||||
}
|
||||
|
||||
if ( m_bReverseThrustersActive )
|
||||
{
|
||||
if ( rand()%3 == 0 )
|
||||
if ( rand() % 3 == 0 )
|
||||
m_ReverseThrusters.Render();
|
||||
}
|
||||
|
||||
CSpaceWarEntity::Render();
|
||||
DWORD actualColor = m_dwShipColor;
|
||||
|
||||
if ( m_nShipPower == 1 ) // Item#103 but need to check if the other guy has it sometimes?
|
||||
{
|
||||
if ( beamCount > 0 )
|
||||
{
|
||||
m_nFade = 255;
|
||||
}
|
||||
else if ( m_nFade > 0 )
|
||||
{
|
||||
m_nFade -= 5;
|
||||
if ( m_nFade < 0 )
|
||||
m_nFade = 0;
|
||||
if ( m_bIsLocalPlayer && m_nFade < 50 )
|
||||
{
|
||||
m_nFade = 128;
|
||||
}
|
||||
}
|
||||
actualColor = (actualColor & 0xffffff) | (m_nFade<<24);
|
||||
}
|
||||
|
||||
DWORD shieldColor = 0x00af8f00;
|
||||
|
||||
if ( m_nShipPower == 2 )
|
||||
{
|
||||
shieldColor = shieldColor | ((m_nShipShieldStrength / 4)<<24);
|
||||
if ( m_nShipShieldStrength < 256 )
|
||||
m_nShipShieldStrength++;
|
||||
|
||||
if ( !m_hTextureWhite )
|
||||
{
|
||||
byte *pRGBAData = new byte[1 * 1 * 4];
|
||||
memset( pRGBAData, 255, 1 * 1 * 4 );
|
||||
m_hTextureWhite = m_pGameEngine->HCreateTexture( pRGBAData, 1, 1 );
|
||||
delete[] pRGBAData;
|
||||
}
|
||||
|
||||
float rotationClockwise = (m_pGameEngine->GetGameTickCount() / 500.0f);
|
||||
float rotationCounter = -(m_pGameEngine->GetGameTickCount() / 500.0f);
|
||||
|
||||
float x1 = 28.0f * cos( rotationClockwise );
|
||||
float y1 = 28.0f * sin( rotationClockwise );
|
||||
float x2 = 28.0f * cos( rotationCounter );
|
||||
float y2 = 28.0f * sin( rotationCounter );
|
||||
|
||||
m_pGameEngine->BDrawTexturedQuad(
|
||||
this->GetXPos() - x1, this->GetYPos() - y1, this->GetXPos() + y1, this->GetYPos() - x1,
|
||||
this->GetXPos() - y1, this->GetYPos() + x1, this->GetXPos() + x1, this->GetYPos() + y1,
|
||||
0, 0, 1, 1, shieldColor, m_hTextureWhite );
|
||||
|
||||
m_pGameEngine->BDrawTexturedQuad(
|
||||
this->GetXPos() - x2, this->GetYPos() - y2, this->GetXPos() + y2, this->GetYPos() - x2,
|
||||
this->GetXPos() - y2, this->GetYPos() + x2, this->GetXPos() + x2, this->GetYPos() + y2,
|
||||
0, 0, 1, 1, shieldColor, m_hTextureWhite );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nShipShieldStrength = 0;
|
||||
}
|
||||
|
||||
CSpaceWarEntity::Render(actualColor);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -584,6 +799,10 @@ void CShip::BuildServerUpdate( ServerShipUpdateData_t *pUpdateData )
|
||||
pUpdateData->SetRotationDeltaLastFrame( GetRotationDeltaLastFrame() );
|
||||
pUpdateData->SetForwardThrustersActive( m_bForwardThrustersActive );
|
||||
pUpdateData->SetReverseThrustersActive( m_bReverseThrustersActive );
|
||||
pUpdateData->SetDecoration( m_nShipDecoration );
|
||||
pUpdateData->SetWeapon( m_nShipWeapon );
|
||||
pUpdateData->SetPower( m_nShipPower );
|
||||
pUpdateData->SetShieldStrength( m_nShipShieldStrength );
|
||||
|
||||
BuildServerPhotonBeamUpdate( pUpdateData );
|
||||
}
|
||||
|
||||
@@ -99,6 +99,9 @@ public:
|
||||
// Set whether the ship is exploding
|
||||
void SetExploding( bool bExploding );
|
||||
|
||||
// Rebuild the geometry when we change decoration
|
||||
void BuildGeometry();
|
||||
|
||||
// Set whether the ship is disabled
|
||||
void SetDisabled( bool bDisabled ) { m_bDisabled = bDisabled; }
|
||||
|
||||
@@ -135,6 +138,9 @@ public:
|
||||
// Get the name for this ship (only really works server side)
|
||||
const char* GetPlayerName();
|
||||
|
||||
int GetShieldStrength() { return m_nShipShieldStrength; }
|
||||
void SetShieldStrength( int strength ) { m_nShipShieldStrength = strength; }
|
||||
|
||||
private:
|
||||
|
||||
// Last time we sent an update on our local data to the server
|
||||
@@ -158,6 +164,9 @@ private:
|
||||
// is the ship disabled for now?
|
||||
bool m_bDisabled;
|
||||
|
||||
// cloak fade out
|
||||
int m_nFade;
|
||||
|
||||
// vector of beams we have fired (in order of firing time)
|
||||
CPhotonBeam * m_rgPhotonBeams[MAX_PHOTON_BEAMS_PER_SHIP];
|
||||
|
||||
@@ -167,6 +176,20 @@ private:
|
||||
// Color for this ship
|
||||
DWORD m_dwShipColor;
|
||||
|
||||
// Decoration for this ship
|
||||
int m_nShipDecoration;
|
||||
|
||||
// Weapon for this ship
|
||||
int m_nShipWeapon;
|
||||
|
||||
// Power for this ship
|
||||
int m_nShipPower;
|
||||
|
||||
// Power for this ship
|
||||
int m_nShipShieldStrength;
|
||||
|
||||
HGAMETEXTURE m_hTextureWhite;
|
||||
|
||||
// Thrusters for this ship
|
||||
CForwardThrusters m_ForwardThrusters;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef SPACEWAR_H
|
||||
#define SPACEWAR_H
|
||||
|
||||
|
||||
// The Steamworks API's are modular, you can use some subsystems without using others
|
||||
// When USE_GS_AUTH_API is defined you get the following Steam features:
|
||||
// - Strong user authentication and authorization
|
||||
@@ -62,7 +63,7 @@
|
||||
#define PHOTON_BEAM_FIRE_INTERVAL_TICKS 250
|
||||
|
||||
// Amount of space needed for beams per ship
|
||||
#define MAX_PHOTON_BEAMS_PER_SHIP PHOTON_BEAM_LIFETIME_IN_TICKS/PHOTON_BEAM_FIRE_INTERVAL_TICKS
|
||||
#define MAX_PHOTON_BEAMS_PER_SHIP (PHOTON_BEAM_LIFETIME_IN_TICKS/PHOTON_BEAM_FIRE_INTERVAL_TICKS)
|
||||
|
||||
// Time to timeout a connection attempt in
|
||||
#define MILLISECONDS_CONNECTION_TIMEOUT 30000
|
||||
@@ -177,6 +178,7 @@ enum EClientGameState
|
||||
k_EClientFindLANServers,
|
||||
k_EClientRemoteStorage,
|
||||
k_EClientLeaderboards,
|
||||
k_EClientFriendsList,
|
||||
k_EClientMinidump,
|
||||
k_EClientConnectingToSteam,
|
||||
k_EClientLinkSteamAccount,
|
||||
@@ -280,6 +282,18 @@ struct ServerShipUpdateData_t
|
||||
void SetReverseThrustersActive( bool bActive ) { m_bReverseThrustersActive = bActive; }
|
||||
bool GetReverseThrustersActive() { return m_bReverseThrustersActive; }
|
||||
|
||||
void SetDecoration( int nDecoration ) { m_nShipDecoration = nDecoration; }
|
||||
int GetDecoration() { return m_nShipDecoration; }
|
||||
|
||||
void SetWeapon( int nWeapon ) { m_nShipWeapon = nWeapon; }
|
||||
int GetWeapon() { return m_nShipWeapon; }
|
||||
|
||||
void SetPower( int nPower ) { m_nShipPower = nPower; }
|
||||
int GetPower() { return m_nShipPower; }
|
||||
|
||||
void SetShieldStrength( int nShieldStrength ) { m_nShieldStrength = nShieldStrength; }
|
||||
int GetShieldStrength() { return m_nShieldStrength; }
|
||||
|
||||
ServerPhotonBeamUpdateData_t *AccessPhotonBeamData( int iIndex ) { return &m_PhotonBeamData[iIndex]; }
|
||||
|
||||
private:
|
||||
@@ -311,6 +325,16 @@ private:
|
||||
bool m_bForwardThrustersActive;
|
||||
bool m_bReverseThrustersActive;
|
||||
|
||||
// Decoration for this ship
|
||||
int m_nShipDecoration;
|
||||
|
||||
// Weapon for this ship
|
||||
int m_nShipWeapon;
|
||||
|
||||
// Power for this ship
|
||||
int m_nShipPower;
|
||||
int m_nShieldStrength;
|
||||
|
||||
// Photon beam positions and data
|
||||
ServerPhotonBeamUpdateData_t m_PhotonBeamData[MAX_PHOTON_BEAMS_PER_SHIP];
|
||||
};
|
||||
@@ -378,6 +402,18 @@ struct ClientSpaceWarUpdateData_t
|
||||
void SetReverseThrustersPressed( bool bIsPressed ) { m_bReverseThrustersPressed = bIsPressed; }
|
||||
bool GetReverseThrustersPressed() { return m_bReverseThrustersPressed; }
|
||||
|
||||
void SetDecoration( int nDecoration ) { m_nShipDecoration = nDecoration; }
|
||||
int GetDecoration() { return m_nShipDecoration; }
|
||||
|
||||
void SetWeapon( int nWeapon ) { m_nShipWeapon = nWeapon; }
|
||||
int GetWeapon() { return m_nShipWeapon; }
|
||||
|
||||
void SetPower( int nPower ) { m_nShipPower = nPower; }
|
||||
int GetPower() { return m_nShipPower; }
|
||||
|
||||
void SetShieldStrength( int nShieldPower ) { m_nShieldStrength = nShieldPower; }
|
||||
int GetShieldStrength() { return m_nShieldStrength; }
|
||||
|
||||
private:
|
||||
// Key's which are done
|
||||
bool m_bFirePressed;
|
||||
@@ -386,6 +422,17 @@ private:
|
||||
bool m_bForwardThrustersPressed;
|
||||
bool m_bReverseThrustersPressed;
|
||||
|
||||
// Decoration for this ship
|
||||
int m_nShipDecoration;
|
||||
|
||||
// Weapon for this ship
|
||||
int m_nShipWeapon;
|
||||
|
||||
// Power for this ship
|
||||
int m_nShipPower;
|
||||
|
||||
int m_nShieldStrength;
|
||||
|
||||
// Name of the player (needed server side to tell master server about)
|
||||
// bugbug jmccaskey - Really lame to send this every update instead of event driven...
|
||||
char m_rgchPlayerName[64];
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
#include "time.h"
|
||||
#include "ServerBrowser.h"
|
||||
#include "Leaderboards.h"
|
||||
#include "Friends.h"
|
||||
#include "musicplayer.h"
|
||||
#include "clanchatroom.h"
|
||||
#include "Lobby.h"
|
||||
#include "p2pauth.h"
|
||||
#include "voicechat.h"
|
||||
#include "htmlsurface.h"
|
||||
#include "Inventory.h"
|
||||
#include "steam/steamencryptedappticket.h"
|
||||
#ifdef WIN32
|
||||
#include <direct.h>
|
||||
@@ -148,6 +150,7 @@ void CSpaceWarClient::Init( IGameEngine *pGameEngine )
|
||||
// Init stats
|
||||
m_pStatsAndAchievements = new CStatsAndAchievements( pGameEngine );
|
||||
m_pLeaderboards = new CLeaderboards( pGameEngine );
|
||||
m_pFriendsList = new CFriendsList( pGameEngine );
|
||||
m_pMusicPlayer = new CMusicPlayer( pGameEngine );
|
||||
m_pClanChatRoom = new CClanChatRoom( pGameEngine );
|
||||
|
||||
@@ -930,6 +933,15 @@ void CSpaceWarClient::OnMenuSelection( LeaderboardMenuItem_t selection )
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles menu actions when viewing a leaderboard
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSpaceWarClient::OnMenuSelection( FriendsListMenuItem_t selection )
|
||||
{
|
||||
m_pFriendsList->OnMenuSelection( selection );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles menu actions when viewing the remote storage sync screen
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -987,11 +999,17 @@ void CSpaceWarClient::OnGameStateChanged( EClientGameState eGameStateNew )
|
||||
}
|
||||
|
||||
SteamFriends()->SetRichPresence( "status", "Main menu" );
|
||||
|
||||
// Refresh inventory
|
||||
SpaceWarLocalInventory()->RefreshFromServer();
|
||||
}
|
||||
else if ( m_eGameState == k_EClientGameWinner || m_eGameState == k_EClientGameDraw )
|
||||
{
|
||||
// game over.. update the leaderboard
|
||||
m_pLeaderboards->UpdateLeaderboards( m_pStatsAndAchievements );
|
||||
|
||||
// Check if the user is due for an item drop
|
||||
SpaceWarLocalInventory()->CheckForItemDrops();
|
||||
}
|
||||
else if ( m_eGameState == k_EClientLeaderboards )
|
||||
{
|
||||
@@ -999,6 +1017,12 @@ void CSpaceWarClient::OnGameStateChanged( EClientGameState eGameStateNew )
|
||||
m_pLeaderboards->Show();
|
||||
SteamFriends()->SetRichPresence( "status", "Viewing leaderboards" );
|
||||
}
|
||||
else if ( m_eGameState == k_EClientFriendsList )
|
||||
{
|
||||
// we've switched to the friends list menu
|
||||
m_pFriendsList->Show();
|
||||
SteamFriends()->SetRichPresence( "status", "Viewing friends list" );
|
||||
}
|
||||
else if ( m_eGameState == k_EClientClanChatRoom )
|
||||
{
|
||||
// we've switched to the leaderboard menu
|
||||
@@ -1007,6 +1031,9 @@ void CSpaceWarClient::OnGameStateChanged( EClientGameState eGameStateNew )
|
||||
}
|
||||
else if ( m_eGameState == k_EClientGameActive )
|
||||
{
|
||||
// Load Inventory
|
||||
SpaceWarLocalInventory()->RefreshFromServer();
|
||||
|
||||
// start voice chat
|
||||
m_pVoiceChat->StartVoiceChat();
|
||||
SteamFriends()->SetRichPresence( "status", "In match" );
|
||||
@@ -1349,6 +1376,10 @@ void CSpaceWarClient::RunFrame()
|
||||
|
||||
if ( bEscapePressed )
|
||||
SetGameState( k_EClientGameMenu );
|
||||
if (m_pGameEngine->BIsKeyDown( 0x31 ) )
|
||||
{
|
||||
SpaceWarLocalInventory()->DoExchange();
|
||||
}
|
||||
break;
|
||||
case k_EClientLeaderboards:
|
||||
m_pStarField->Render();
|
||||
@@ -1358,6 +1389,14 @@ void CSpaceWarClient::RunFrame()
|
||||
SetGameState( k_EClientGameMenu );
|
||||
break;
|
||||
|
||||
case k_EClientFriendsList:
|
||||
m_pStarField->Render();
|
||||
m_pFriendsList->RunFrame();
|
||||
|
||||
if ( bEscapePressed )
|
||||
SetGameState( k_EClientGameMenu );
|
||||
break;
|
||||
|
||||
case k_EClientClanChatRoom:
|
||||
m_pStarField->Render();
|
||||
m_pClanChatRoom->RunFrame();
|
||||
@@ -1425,7 +1464,9 @@ void CSpaceWarClient::RunFrame()
|
||||
case k_EClientGameActive:
|
||||
m_pStarField->Render();
|
||||
|
||||
|
||||
// SendHeartbeat is safe to call on every frame since the API is internally rate-limited.
|
||||
// Ideally you would only call this once per second though, to minimize unnecessary calls.
|
||||
SteamInventory()->SendItemDropHeartbeat();
|
||||
|
||||
// Update all the entities...
|
||||
m_pSun->RunFrame();
|
||||
@@ -1643,7 +1684,7 @@ void CSpaceWarClient::DrawHUDText()
|
||||
|
||||
if ( hTexture )
|
||||
{
|
||||
m_pGameEngine->BDrawTexturedQuad( (float)rect.left, (float)rect.top, (float)rect.left+nAvatarWidth, (float)rect.bottom,
|
||||
m_pGameEngine->BDrawTexturedRect( (float)rect.left, (float)rect.top, (float)rect.left+nAvatarWidth, (float)rect.bottom,
|
||||
0.0f, 0.0f, 1.0, 1.0, D3DCOLOR_ARGB( 255, 255, 255, 255 ), hTexture );
|
||||
rect.left += nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
rect.right += nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
@@ -1661,7 +1702,7 @@ void CSpaceWarClient::DrawHUDText()
|
||||
|
||||
if ( hTexture )
|
||||
{
|
||||
m_pGameEngine->BDrawTexturedQuad( (float)rect.right - nAvatarWidth, (float)rect.top, (float)rect.right, (float)rect.bottom,
|
||||
m_pGameEngine->BDrawTexturedRect( (float)rect.right - nAvatarWidth, (float)rect.top, (float)rect.right, (float)rect.bottom,
|
||||
0.0f, 0.0f, 1.0, 1.0, D3DCOLOR_ARGB( 255, 255, 255, 255 ), hTexture );
|
||||
rect.right -= nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
rect.left -= nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
@@ -1678,7 +1719,7 @@ void CSpaceWarClient::DrawHUDText()
|
||||
|
||||
if ( hTexture )
|
||||
{
|
||||
m_pGameEngine->BDrawTexturedQuad( (float)rect.left, (float)rect.top, (float)rect.left+nAvatarWidth, (float)rect.bottom,
|
||||
m_pGameEngine->BDrawTexturedRect( (float)rect.left, (float)rect.top, (float)rect.left+nAvatarWidth, (float)rect.bottom,
|
||||
0.0f, 0.0f, 1.0, 1.0, D3DCOLOR_ARGB( 255, 255, 255, 255 ), hTexture );
|
||||
rect.right += nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
rect.left += nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
@@ -1695,7 +1736,7 @@ void CSpaceWarClient::DrawHUDText()
|
||||
|
||||
if ( hTexture )
|
||||
{
|
||||
m_pGameEngine->BDrawTexturedQuad( (float)rect.right - nAvatarWidth, (float)rect.top, (float)rect.right, (float)rect.bottom,
|
||||
m_pGameEngine->BDrawTexturedRect( (float)rect.right - nAvatarWidth, (float)rect.top, (float)rect.right, (float)rect.bottom,
|
||||
0.0f, 0.0f, 1.0, 1.0, D3DCOLOR_ARGB( 255, 255, 255, 255 ), hTexture );
|
||||
rect.right -= nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
rect.left -= nAvatarWidth + nSpaceBetweenAvatarAndScore;
|
||||
@@ -1740,7 +1781,7 @@ void CSpaceWarClient::DrawInstructions()
|
||||
rect.top = LONG(m_pGameEngine->GetViewportHeight() * 0.7);
|
||||
rect.bottom = m_pGameEngine->GetViewportHeight();
|
||||
|
||||
sprintf_safe( rgchBuffer, "Press ESC to return to the Main Menu" );
|
||||
sprintf_safe( rgchBuffer, "Press ESC to return to the Main Menu\n Build ID:%d", SteamApps()->GetAppBuildId() );
|
||||
m_pGameEngine->BDrawString( m_hInstructionsFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_CENTER|TEXTPOS_TOP, rgchBuffer );
|
||||
|
||||
}
|
||||
@@ -1811,6 +1852,8 @@ void CSpaceWarClient::DrawConnectionFailureText()
|
||||
void CSpaceWarClient::DrawWinnerDrawOrWaitingText()
|
||||
{
|
||||
int nSecondsToRestart = ((MILLISECONDS_BETWEEN_ROUNDS - (int)(m_pGameEngine->GetGameTickCount() - m_ulStateTransitionTime) )/1000) + 1;
|
||||
if ( nSecondsToRestart < 0 )
|
||||
nSecondsToRestart = 0;
|
||||
|
||||
RECT rect;
|
||||
rect.top = 0;
|
||||
@@ -1851,6 +1894,20 @@ void CSpaceWarClient::DrawWinnerDrawOrWaitingText()
|
||||
|
||||
m_pGameEngine->BDrawString( m_hInstructionsFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_CENTER|TEXTPOS_VCENTER, rgchBuffer );
|
||||
}
|
||||
|
||||
// Note: GetLastDroppedItem is the result of an async function, this will not render the reward right away. Could wait for it.
|
||||
const CSpaceWarItem *pItem = SpaceWarLocalInventory()->GetLastDroppedItem();
|
||||
if ( pItem )
|
||||
{
|
||||
// (We're not really bothering to localize everything else, this is just an example.)
|
||||
sprintf_safe( rgchBuffer, "You won a brand new %s!", pItem->GetLocalizedName().c_str() );
|
||||
|
||||
rect.top = 0;
|
||||
rect.bottom = int(m_pGameEngine->GetViewportHeight()*0.4f);
|
||||
rect.left = 0;
|
||||
rect.right = m_pGameEngine->GetViewportWidth();
|
||||
m_pGameEngine->BDrawString( m_hInstructionsFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_CENTER|TEXTPOS_VCENTER, rgchBuffer );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2252,4 +2309,3 @@ void CSpaceWarClient::DrawWorkshopItems()
|
||||
sprintf_safe(rgchBuffer, "Press ESC to return to the Main Menu");
|
||||
m_pGameEngine->BDrawString(m_hInstructionsFont, rect, D3DCOLOR_ARGB(255, 25, 200, 25), TEXTPOS_CENTER | TEXTPOS_TOP, rgchBuffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ class CServerBrowser;
|
||||
class CLobbyBrowser;
|
||||
class CLobby;
|
||||
class CLeaderboards;
|
||||
class CFriendsList;
|
||||
class CClanChatRoom;
|
||||
class CP2PAuthPlayer;
|
||||
class CP2PAuthedGame;
|
||||
@@ -86,6 +87,12 @@ struct LeaderboardMenuItem_t
|
||||
bool m_bNextLeaderboard;
|
||||
};
|
||||
|
||||
// a friends list item
|
||||
struct FriendsListMenuItem_t
|
||||
{
|
||||
CSteamID m_steamIDFriend;
|
||||
};
|
||||
|
||||
#define MAX_WORKSHOP_ITEMS 16
|
||||
|
||||
// a Steam Workshop item
|
||||
@@ -166,6 +173,7 @@ public:
|
||||
|
||||
void OnMenuSelection( LobbyMenuItem_t selection );
|
||||
void OnMenuSelection( LeaderboardMenuItem_t selection );
|
||||
void OnMenuSelection( FriendsListMenuItem_t selection );
|
||||
void OnMenuSelection( ERemoteStorageSyncMenuCommand selection );
|
||||
|
||||
void OnMenuSelection( MusicPlayerMenuItem_t selection ) { m_pMusicPlayer->OnMenuSelection( selection ); }
|
||||
@@ -383,6 +391,7 @@ private:
|
||||
CStatsAndAchievements *m_pStatsAndAchievements;
|
||||
|
||||
CLeaderboards *m_pLeaderboards;
|
||||
CFriendsList *m_pFriendsList;
|
||||
CMusicPlayer *m_pMusicPlayer;
|
||||
CClanChatRoom *m_pClanChatRoom;
|
||||
CServerBrowser *m_pServerBrowser;
|
||||
|
||||
@@ -801,7 +801,10 @@ void CSpaceWarServer::CheckForCollisions()
|
||||
if ( !m_rgpShips[i] )
|
||||
continue;
|
||||
|
||||
rgbExplodingShips[i] |= m_rgpShips[i]->BCollidesWith( m_pSun );
|
||||
if ( m_rgpShips[i]->BCollidesWith( m_pSun ) )
|
||||
{
|
||||
rgbExplodingShips[i] |= 1;
|
||||
}
|
||||
|
||||
for( uint32 j=0; j<MAX_PLAYERS_PER_SERVER; ++j )
|
||||
{
|
||||
@@ -810,7 +813,19 @@ void CSpaceWarServer::CheckForCollisions()
|
||||
continue;
|
||||
|
||||
rgbExplodingShips[i] |= m_rgpShips[i]->BCollidesWith( m_rgpShips[j] );
|
||||
rgbExplodingShips[i] |= m_rgpShips[j]->BCheckForPhotonsCollidingWith( m_rgpShips[i] );
|
||||
if ( m_rgpShips[j]->BCheckForPhotonsCollidingWith( m_rgpShips[i] ) )
|
||||
{
|
||||
if ( m_rgpShips[i]->GetShieldStrength() > 200 )
|
||||
{
|
||||
// Shield protects from the hit
|
||||
m_rgpShips[i]->SetShieldStrength( 0 );
|
||||
m_rgpShips[j]->DestroyPhotonsColldingWith( m_rgpShips[i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
rgbExplodingShips[i] |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "StatsAndAchievements.h"
|
||||
#include "Inventory.h"
|
||||
#include <math.h>
|
||||
#include "SpaceWarClient.h"
|
||||
|
||||
@@ -459,7 +460,7 @@ void CStatsAndAchievements::Render()
|
||||
{
|
||||
// COLUMN 1
|
||||
// Achievements above the midline
|
||||
int32 pxVertOffset = height / 2 - 2 * ( ACHDISP_IMG_SIZE + ACHDISP_VERT_SPACING );
|
||||
int32 pxVertOffset = height / 2 - 3 * ( ACHDISP_IMG_SIZE + ACHDISP_VERT_SPACING );
|
||||
rect.top = pxVertOffset;
|
||||
rect.bottom = rect.top + ACHDISP_IMG_SIZE;
|
||||
rect.left = pxColumn1Left;
|
||||
@@ -475,7 +476,7 @@ void CStatsAndAchievements::Render()
|
||||
DrawAchievementInfo( rect, g_rgAchievements[1] );
|
||||
|
||||
// Stats below the midline
|
||||
pxVertOffset = height / 2 + ACHDISP_VERT_SPACING;
|
||||
pxVertOffset = height / 2 + ACHDISP_VERT_SPACING - 1 * ( ACHDISP_IMG_SIZE + ACHDISP_VERT_SPACING );
|
||||
|
||||
rect.top = pxVertOffset;
|
||||
rect.bottom = rect.top + ACHDISP_FONT_HEIGHT;
|
||||
@@ -495,9 +496,26 @@ void CStatsAndAchievements::Render()
|
||||
|
||||
DrawStatInfo( rect, "Games Lost", static_cast<float>( m_nTotalNumLosses ) );
|
||||
|
||||
rect.top = pxVertOffset;
|
||||
rect.bottom = rect.top + ACHDISP_FONT_HEIGHT;
|
||||
pxVertOffset = rect.bottom + ACHDISP_VERT_SPACING;
|
||||
|
||||
m_pGameEngine->BDrawString( m_hDisplayFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_LEFT|TEXTPOS_VCENTER, "Inventory" );
|
||||
|
||||
std::list<CSpaceWarItem *>::const_iterator iter;
|
||||
for ( iter = SpaceWarLocalInventory()->GetItemList().begin(); iter != SpaceWarLocalInventory()->GetItemList().end(); ++iter )
|
||||
{
|
||||
rect.top = pxVertOffset;
|
||||
rect.bottom = rect.top + ACHDISP_FONT_HEIGHT;
|
||||
pxVertOffset = rect.bottom + ACHDISP_VERT_SPACING;
|
||||
|
||||
DrawInventory( rect, ( *iter )->GetItemId() );
|
||||
}
|
||||
|
||||
|
||||
// COLUMN 2
|
||||
// Achievements above the midline
|
||||
pxVertOffset = height / 2 - 2 * ( ACHDISP_IMG_SIZE + ACHDISP_VERT_SPACING );
|
||||
pxVertOffset = height / 2 - 3 * ( ACHDISP_IMG_SIZE + ACHDISP_VERT_SPACING );
|
||||
|
||||
rect.top = pxVertOffset;
|
||||
rect.bottom = rect.top + ACHDISP_IMG_SIZE;
|
||||
@@ -514,7 +532,7 @@ void CStatsAndAchievements::Render()
|
||||
DrawAchievementInfo( rect, g_rgAchievements[3] );
|
||||
|
||||
// Stats below the midline
|
||||
pxVertOffset = height / 2 + ACHDISP_VERT_SPACING;
|
||||
pxVertOffset = height / 2 + ACHDISP_VERT_SPACING - 1 * ( ACHDISP_IMG_SIZE + ACHDISP_VERT_SPACING );
|
||||
|
||||
rect.top = pxVertOffset;
|
||||
rect.bottom = rect.top + ACHDISP_FONT_HEIGHT;
|
||||
@@ -537,7 +555,7 @@ void CStatsAndAchievements::Render()
|
||||
// Footer
|
||||
rect.left = 0;
|
||||
rect.right = width;
|
||||
rect.top = LONG(m_pGameEngine->GetViewportHeight() * 0.7);
|
||||
rect.top = LONG(m_pGameEngine->GetViewportHeight() * 0.8);
|
||||
rect.bottom = m_pGameEngine->GetViewportHeight();
|
||||
|
||||
char rgchBuffer[256];
|
||||
@@ -562,7 +580,7 @@ void CStatsAndAchievements::DrawAchievementInfo( RECT &rect, Achievement_t &ach
|
||||
// could still be zero if the image isn't downloaded yet
|
||||
if (hTexture )
|
||||
{
|
||||
m_pGameEngine->BDrawTexturedQuad( (float)rect2.left, (float)rect2.top, (float)rect2.left+ACHDISP_IMG_SIZE, (float)rect2.bottom,
|
||||
m_pGameEngine->BDrawTexturedRect( (float)rect2.left, (float)rect2.top, (float)rect2.left+ACHDISP_IMG_SIZE, (float)rect2.bottom,
|
||||
0.0f, 0.0f, 1.0, 1.0, D3DCOLOR_ARGB( 255, 255, 255, 255 ), hTexture );
|
||||
|
||||
rect2.left += ACHDISP_IMG_SIZE + ACHDISP_IMG_PAD;
|
||||
@@ -586,6 +604,18 @@ void CStatsAndAchievements::DrawStatInfo( RECT &rect, const char *pchName, float
|
||||
m_pGameEngine->BDrawString( m_hDisplayFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_LEFT|TEXTPOS_VCENTER, rgchBuffer );
|
||||
}
|
||||
|
||||
void CStatsAndAchievements::DrawInventory( RECT &rect, SteamItemInstanceID_t itemid )
|
||||
{
|
||||
const CSpaceWarItem *pItem = SpaceWarLocalInventory()->GetItem( itemid );
|
||||
if ( pItem == nullptr )
|
||||
return;
|
||||
|
||||
// todo: divide up so can draw image
|
||||
char rgchBuffer[256];
|
||||
sprintf_safe( rgchBuffer, "%s", pItem->GetLocalizedName().c_str() );
|
||||
m_pGameEngine->BDrawString( m_hDisplayFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_LEFT|TEXTPOS_VCENTER, rgchBuffer );
|
||||
}
|
||||
|
||||
bool CStatsAndAchievements::LoadUserStatsOnPS3()
|
||||
{
|
||||
#ifdef _PS3
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "SpaceWar.h"
|
||||
#include "GameEngine.h"
|
||||
#include "Inventory.h"
|
||||
|
||||
enum EAchievements
|
||||
{
|
||||
@@ -73,6 +74,7 @@ private:
|
||||
// Render helpers
|
||||
void DrawAchievementInfo( RECT &rect, Achievement_t &ach );
|
||||
void DrawStatInfo( RECT &rect, const char *pchName, float flValue );
|
||||
void DrawInventory( RECT &rect, SteamItemInstanceID_t itemid );
|
||||
|
||||
// PS3 specific
|
||||
bool LoadUserStatsOnPS3();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30723.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SteamworksExample", "SteamworksExample.vcproj", "{F9B80FD0-A31F-443F-9FFF-85813D209141}"
|
||||
EndProject
|
||||
Global
|
||||
|
||||
@@ -393,10 +393,18 @@
|
||||
RelativePath=".\connectingmenu.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Friends.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\htmlsurface.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Inventory.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Leaderboards.cpp"
|
||||
>
|
||||
@@ -507,10 +515,18 @@
|
||||
RelativePath=".\connectingmenu.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Friends.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\htmlsurface.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Inventory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Leaderboards.h"
|
||||
>
|
||||
|
||||
@@ -69,7 +69,10 @@ void CVectorEntity::AddLine( float xPos0, float yPos0, float xPos1, float yPos1,
|
||||
m_VecVertexes.push_back( vert );
|
||||
}
|
||||
|
||||
|
||||
void CVectorEntity::ClearVertexes()
|
||||
{
|
||||
m_VecVertexes.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Set the current position for the object
|
||||
@@ -125,20 +128,21 @@ void CVectorEntity::RunFrame()
|
||||
|
||||
// Update our acceleration, velocity, and finally position
|
||||
// Note: The min here is so we don't get massive acceleration if frames for some reason don't run for a bit
|
||||
float ulElapsedSeconds = MIN( (float)m_pGameEngine->GetGameTicksFrameDelta() / 1000.0f, 2 );
|
||||
float ulElapsedSeconds = MIN( (float)m_pGameEngine->GetGameTicksFrameDelta() / 1000.0f, 0.1f );
|
||||
m_flXVelocity += m_flXAccel * ulElapsedSeconds;
|
||||
m_flYVelocity += m_flYAccel * ulElapsedSeconds;
|
||||
|
||||
// Make sure velocity does not exceed maximum allowed
|
||||
if ( m_flXVelocity > 0 && m_flXVelocity > m_flMaximumVelocity )
|
||||
m_flXVelocity = m_flMaximumVelocity;
|
||||
else if ( m_flXVelocity < 0 && m_flYVelocity < -1.0f*m_flMaximumVelocity )
|
||||
m_flXVelocity = -1.0f * m_flMaximumVelocity;
|
||||
|
||||
if ( m_flYVelocity > 0 && m_flYVelocity > m_flMaximumVelocity )
|
||||
m_flYVelocity = m_flMaximumVelocity;
|
||||
else if ( m_flYVelocity < 0 && m_flYVelocity < -1.0f*m_flMaximumVelocity )
|
||||
m_flYVelocity = -1.0f * m_flMaximumVelocity;
|
||||
float flVelocity = sqrt( m_flXVelocity*m_flXVelocity + m_flYVelocity*m_flYVelocity );
|
||||
|
||||
if ( flVelocity > m_flMaximumVelocity )
|
||||
{
|
||||
float flRatio = m_flMaximumVelocity / flVelocity;
|
||||
|
||||
m_flXVelocity = m_flXVelocity * flRatio;
|
||||
m_flYVelocity = m_flYVelocity * flRatio;
|
||||
}
|
||||
|
||||
m_flXPos += m_flXVelocity * ulElapsedSeconds;
|
||||
m_flYPos += m_flYVelocity * ulElapsedSeconds;
|
||||
@@ -174,6 +178,9 @@ void CVectorEntity::Render()
|
||||
float flSinRotation = (float)sin(m_flAccumulatedRotation);
|
||||
float flCosRotation = (float)cos(m_flAccumulatedRotation);
|
||||
|
||||
if ( m_VecVertexes.size() < 2 )
|
||||
return;
|
||||
|
||||
// Iterate our vector of vertexes 2 at a time drawing lines
|
||||
for( size_t i=0; i < m_VecVertexes.size() - 1; ++i )
|
||||
{
|
||||
@@ -215,6 +222,56 @@ void CVectorEntity::Render()
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Render the entity with an override color instead of the vertex color
|
||||
//-----------------------------------------------------------------------------
|
||||
void CVectorEntity::Render(DWORD overrideColor)
|
||||
{
|
||||
// Compute values which will be used for rotation below
|
||||
float flSinRotation = (float)sin(m_flAccumulatedRotation);
|
||||
float flCosRotation = (float)cos(m_flAccumulatedRotation);
|
||||
|
||||
// Iterate our vector of vertexes 2 at a time drawing lines
|
||||
for( size_t i=0; i < m_VecVertexes.size() - 1; ++i )
|
||||
{
|
||||
DWORD dwColor0, dwColor1;
|
||||
float xPos0, yPos0, xPos1, yPos1;
|
||||
float xPrime0, yPrime0, xPrime1, yPrime1;
|
||||
|
||||
// Grab the first point and apply rotation and translation
|
||||
xPos0 = m_VecVertexes[i].x;
|
||||
yPos0 = m_VecVertexes[i].y;
|
||||
dwColor0 = overrideColor;
|
||||
|
||||
// Apply any needed rotation
|
||||
xPrime0 = flCosRotation*xPos0 - flSinRotation*yPos0;
|
||||
yPrime0 = flSinRotation*xPos0 + flCosRotation*yPos0;
|
||||
|
||||
// Apply translation to current position
|
||||
xPrime0 += m_flXPos;
|
||||
yPrime0 += m_flYPos;
|
||||
|
||||
// Next vertex, we use 2 per iteration
|
||||
++i;
|
||||
|
||||
// Grab the second point and apply rotation and translation
|
||||
xPos1 = m_VecVertexes[i].x;
|
||||
yPos1 = m_VecVertexes[i].y;
|
||||
dwColor1 = overrideColor;
|
||||
|
||||
// Apply any needed rotation
|
||||
xPrime1 = flCosRotation*xPos1 - flSinRotation*yPos1;
|
||||
yPrime1 = flSinRotation*xPos1 + flCosRotation*yPos1;
|
||||
|
||||
// Apply translation to current position
|
||||
xPrime1 += m_flXPos;
|
||||
yPrime1 += m_flYPos;
|
||||
|
||||
// Have the game engine draw the actual line (it batches these operations)
|
||||
m_pGameEngine->BDrawLine( xPrime0, yPrime0, dwColor0, xPrime1, yPrime1, dwColor1 );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Check if the entity is colliding with the other given entity
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -18,7 +18,7 @@ struct VectorEntityVertex_t
|
||||
DWORD color;
|
||||
};
|
||||
|
||||
#define DEFAULT_MAXIMUM_VELOCITY 350.0f
|
||||
#define DEFAULT_MAXIMUM_VELOCITY 450.0f
|
||||
|
||||
#define PI_VALUE 3.14159265f
|
||||
|
||||
@@ -37,6 +37,9 @@ public:
|
||||
// Render the sun field
|
||||
virtual void Render();
|
||||
|
||||
// Render with an explicit color
|
||||
virtual void Render(DWORD overrideColor);
|
||||
|
||||
// Check if the entity is colliding with another given entity
|
||||
bool BCollidesWith( CVectorEntity * pTarget );
|
||||
|
||||
@@ -71,6 +74,9 @@ public:
|
||||
// Add a line to the entity
|
||||
void AddLine(float xPos0, float yPos0, float xPos1, float yPos1, DWORD dwColor);
|
||||
|
||||
// Clear all lines in the entity
|
||||
void ClearVertexes();
|
||||
|
||||
// Set the objects current position
|
||||
void SetPosition(float xPos, float yPos);
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ extern void OutputDebugString( const char *pchMsg );
|
||||
extern int Alert( const char *lpCaption, const char *lpText );
|
||||
extern const char *GetUserSaveDataPath();
|
||||
|
||||
#define Q_ARRAYSIZE(a) sizeof(a)/sizeof(a[0])
|
||||
#define V_ARRAYSIZE(a) sizeof(a)/sizeof(a[0])
|
||||
|
||||
#endif // POSIX
|
||||
|
||||
|
||||
Reference in New Issue
Block a user