Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Why am I getting this error? (Un)resolved External Symbol

$
0
0
Hello D.I.C.ers.

I've encountered this error enough to know that it usually means a static object wasn't defined or initialized but I'm pretty sure I've done that. Here's the file where it keeps screwing up. Trying to test my Quadtree and can't figure out why it won't accept my code.

The error is:

Quote

1>Game.obj : error LNK2001: unresolved external symbol "public: static class CQuadTreeNode * Game::ScreenNode" (?ScreenNode@Game@@2PAVCQuadTreeNode@@A)
1>F:\Users\Dark Glitch\Documents\Visual Studio 2010\Projects\Pang Tutorial\Debug\Pang Tutorial.exe : fatal error LNK1120: 1 unresolved externals


#include "stdafx.h"
#include "Game.h"
#include "Main_Menu.h"
#include "SplashScreen.h"

CQuadTreeNode* ScreenNode = new CQuadTreeNode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, NULL );

void Game::Start()
{
	if( _gameState != Uninitialized )
	{
		return;
	}

	_mainwindow.Create( sf::VideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 32 ), "");

	MainPlayerEntity* _player1 = new MainPlayerEntity();
	_player1->Load( "TestPlayer" );
	_player1->SetPosition( 600, 700 );

	ScreenNode->AddObject( _player1 );
	

	PlayerPaddle* _Test = new PlayerPaddle();
	_Test->SetPosition( 100, 700 );

	ScreenNode->AddObject( _Test );
	
	_gameState = Game::ShowingSplash;

	while( !IsExiting() )
	{
		GameLoop();
	}

	_mainwindow.Close();
}

const sf::Input& Game::GetInput() 
{
	return _mainwindow.GetInput();
}

bool Game::IsExiting()
{
	if( _gameState == Game::Exiting )
	{
		return true;
	}

	else
		return false;
}

sf::RenderWindow& Game::GetWindow()
{
	return _mainWindow;
}

void Game::GameLoop()
{
	sf::Event currentEvent;
	_mainwindow.GetEvent( currentEvent );

	switch( _gameState )
	{
	case Game::ShowingMenu:
		{
			ShowMenu();
			break;
		}
	
	case Game::ShowingSplash:
		{
			ShowSplashScreen();
			break;
		}

	case Game::Playing:
		{
			_mainwindow.Clear( sf::Color( 0, 0, 0 ) );
			
			ScreenNode->Update( _mainwindow.GetFrameTime() );

			_mainwindow.Display();
				
			if( currentEvent.Type == sf::Event::Closed )
			{
				_gameState = Game::Exiting;
			}

			if( currentEvent.Type == sf::Event::KeyPressed )
			{
				if( currentEvent.Key.Code == sf::Key::Escape ) 
				{
					ShowMenu();
				}
			}
			break;
		}

	default:
		{
			break;
		}
	}
}

void Game::ShowSplashScreen()
{
	SplashScreen splashScreen;
	splashScreen.Show( _mainWindow );
	_gameState = Game::ShowingMenu;
}

void Game::ShowMenu()
{
	Main_Menu mainMenu;
	Main_Menu::MenuResult result = mainMenu.Show( _mainWindow );

	switch( result )
	{
	case Main_Menu::Exit:
		_gameState = Game::Exiting;
		break;

	case Main_Menu::Play:
		_gameState = Game::Playing;
		break;
	}
}

// Static Variable Instances
Game::GameState Game::_gameState = Uninitialized;
sf::RenderWindow Game::_mainWindow;
CQuadTreeNode* ScreenNode = new CQuadTreeNode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, NULL );



Help is appreciated.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>