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

Texturing 3D cmd Game Tutorial Getting 12 Errors and i have no idea what they mean #55

Open
JonSTGaming opened this issue Dec 1, 2020 · 0 comments

Comments

@JonSTGaming
Copy link

Everytime i compile i get 12 errors:
Severity Code Description Project File Line Suppression State Error LNK2001 unresolved external symbol "public: __thiscall olc::Pixel::Pixel(unsigned char,unsigned char,unsigned char,unsigned char)" (??0Pixel@olc@@QAE@EEEE@Z) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: __thiscall olc::Pixel::Pixel(unsigned int)" (??0Pixel@olc@@QAE@I@Z) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: virtual bool __thiscall olc::PixelGameEngine::Draw(int,int,struct olc::Pixel)" (?Draw@PixelGameEngine@olc@@UAE_NHHUPixel@2@@Z) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: int __thiscall olc::PixelGameEngine::ScreenHeight(void)const " (?ScreenHeight@PixelGameEngine@olc@@QBEHXZ) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: int __thiscall olc::PixelGameEngine::ScreenWidth(void)const " (?ScreenWidth@PixelGameEngine@olc@@QBEHXZ) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: struct olc::HWButton __thiscall olc::PixelGameEngine::GetKey(enum olc::Key)const " (?GetKey@PixelGameEngine@olc@@QBE?AUHWButton@2@W4Key@2@@Z) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: virtual bool __thiscall olc::PixelGameEngine::OnUserDestroy(void)" (?OnUserDestroy@PixelGameEngine@olc@@UAE_NXZ) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: enum olc::rcode __thiscall olc::PixelGameEngine::Start(void)" (?Start@PixelGameEngine@olc@@QAE?AW4rcode@2@XZ) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: enum olc::rcode __thiscall olc::PixelGameEngine::Construct(int,int,int,int,bool,bool,bool)" (?Construct@PixelGameEngine@olc@@QAE?AW4rcode@2@HHHH_N00@Z) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: virtual __thiscall olc::PixelGameEngine::~PixelGameEngine(void)" (??1PixelGameEngine@olc@@UAE@XZ) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK2001 unresolved external symbol "public: __thiscall olc::PixelGameEngine::PixelGameEngine(void)" (??0PixelGameEngine@olc@@QAE@XZ) ConFPS C:\Users\Jonathon\source\repos\ConFPS\ConFPS\Source.obj 1 Error LNK1120 11 unresolved externals ConFPS C:\Users\Jonathon\source\repos\ConFPS\Release\ConFPS.exe 1

And here is my Code:
`#include
#include
#include

using namespace std;

#include "olcPixelGameEngine.h"

class GameWindow : public olc::PixelGameEngine
{
public:
GameWindow()
{
sAppName = "Game 3D";

}
virtual bool OnUserCreate()
{
	map += L"################";
	map += L"#..............#";
	map += L"#....###.......#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#..............#";
	map += L"#.......########";
	map += L"#..............#";
	map += L"#..............#";
	map += L"################";
	return true;
}
virtual bool OnUserUpdate(float fElapsedTime)
{
	// Controls
	// Handle CCW rotation
	if (GetKey(olc::Key::A).bHeld)
		fPlayerA -= (0.8) * fElapsedTime;

	if (GetKey(olc::Key::D).bHeld)
		fPlayerA += (0.8) * fElapsedTime;

	if (GetKey(olc::Key::W).bHeld)
	{
		fPlayerX += sinf(fPlayerA) * 5.0f * fElapsedTime;
		fPlayerY += cosf(fPlayerA) * 5.0f * fElapsedTime;

		if (map[(int)fPlayerY * nMapWidth + (int)fPlayerX] == '#')
		{
			fPlayerX -= sinf(fPlayerA) * 5.0f * fElapsedTime;
			fPlayerY -= cosf(fPlayerA) * 5.0f * fElapsedTime;
		}
	}
	if (GetKey(olc::Key::S).bHeld)
	{
		fPlayerX -= sinf(fPlayerA) * 5.0f * fElapsedTime;
		fPlayerY -= cosf(fPlayerA) * 5.0f * fElapsedTime;

		if (map[(int)fPlayerY * nMapWidth + (int)fPlayerX] == '#')
		{
			fPlayerX += sinf(fPlayerA) * 5.0f * fElapsedTime;
			fPlayerY += cosf(fPlayerA) * 5.0f * fElapsedTime;
		}
	}

	for (int x = 0; x < ScreenWidth(); x++)
	{
		// For each column, calculate the projected ray angle into world space
		float fRayAngle = (fPlayerA - fFOV / 2.0f) + ((float)x / (float)ScreenWidth()) * fFOV;

		float fDistanceToWall = 0;
		bool bHitWall = false;
		bool bBoundary = false;

		float fEyeX = sinf(fRayAngle);
		float fEyeY = cosf(fRayAngle);

		while (!bHitWall && fDistanceToWall < fDepth)
		{

			fDistanceToWall += 0.1f;

			int nTestX = (int)(fPlayerX + fEyeX * fDistanceToWall);
			int nTestY = (int)(fPlayerY + fEyeY * fDistanceToWall);

			// Test if ray is out of bounds
			if (nTestX < 0 || nTestX >= nMapWidth || nTestY < 0 || nTestY >= nMapHeight)
			{
				bHitWall = true;			// Just set distance to maximum depth
				fDistanceToWall = fDepth;
			}
			else
			{
				if (map[nTestY * nMapWidth + nTestX] == '#')
				{
					bHitWall = true;

					vector<pair<float, float>> p; // distance, dot
					for (int tx = 0; tx < 2; tx++)
						for (int ty = 0; ty < 2; ty++)
						{
							float vy = (float)nTestY + ty - fPlayerY;
							float vx = (float)nTestX + tx - fPlayerX;
							float d = sqrt(vx * vx + vy * vy);
							float dot = (fEyeX * vx / d) + (fEyeY * vy / d);
							p.push_back(make_pair(d, dot));
						}
					// Sort pairs from closest to farthest
					sort(p.begin(), p.end(), [](const pair<float, float>& left, const pair<float, float>& right) {return left.first < right.first;  });

					float fBound = 0.01;
					if (acos(p.at(0).second) < fBound) bBoundary = true;
					if (acos(p.at(1).second) < fBound) bBoundary = true;
					if (acos(p.at(2).second) < fBound) bBoundary = true;
				}
			}
		}

		// Calculate distance to ceiling and floor
		int nCeiling = (float)(ScreenHeight() / 2.0) - ScreenHeight() / ((float)fDistanceToWall);
		int nFloor = ScreenHeight() - nCeiling;

		// Shader walls based on distance
		short nShade = ' ';
		if (fDistanceToWall <= fDepth / 4.0f)			nShade = 0x2588;	// Very close	
		else if (fDistanceToWall < fDepth / 3.0f)		nShade = 0x2593;
		else if (fDistanceToWall < fDepth / 2.0f)		nShade = 0x2592;
		else if (fDistanceToWall < fDepth)				nShade = 0x2591;
		else                                            nShade = ' ';

		if (bBoundary)		nShade = ' '; //Black it out

		for (int i = 0; i < ScreenHeight(); i++)
		{
			if (i <= nCeiling)
				Draw(x, i, L' ');
			else if (i > nCeiling&& i <= nFloor)
				Draw(x, i, nShade);
			else
			{
				// Shade floor based on distance
				float b = 1.0f - (((float)i - ScreenHeight() / 2.0f) / ((float)ScreenHeight() / 2.0f));
				if (b < 0.25)		nShade = '#';
				else if (b < 0.5)	nShade = 'x';
				else if (b < 0.75)	nShade = '.';
				else if (b < 0.9)	nShade = '-';
				else				nShade = ' ';
				Draw(x, i, nShade);
			}

		}
	}
	// Display Map
	for (int nx = 0; nx < nMapWidth; nx++)
		for (int ny = 0; ny < nMapWidth; ny++)
			Draw(nx + 1, ny + 1, map[ny * nMapWidth + nx]);
	Draw(1 + (int)fPlayerY, 1 + (int)fPlayerX, L'P');

	

	return true;
}

private:
int nMapHeight = 16;
int nMapWidth = 16;
wstring map;

float fPlayerX = 8.0f;
float fPlayerY = 8.0f;
float fPlayerA = 0.0f;
float fFOV = 3.14159 / 4.0f;
float fDepth = 16.0f;

};

int main()
{

GameWindow game;
game.Construct(120, 80, 8, 8);
game.Start();
	


return 0;

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant