diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 2088f36..7d69171 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 92149c9..d395aae 100644 --- a/main.cpp +++ b/main.cpp @@ -138,6 +138,7 @@ private: float fTheta=0; float fYaw=0; + float pitch=-M_PI/6; vec3d Matrix_MultiplyVector(mat4x4 &m, vec3d &i) @@ -471,16 +472,10 @@ public: bool OnUserUpdate(float fElapsedTime) override { if (GetKey(olc::DOWN).bHeld) { - vCamera.y-=8*fElapsedTime; + pitch-=1*fElapsedTime; } if (GetKey(olc::UP).bHeld) { - vCamera.y+=8*fElapsedTime; - } - if (GetKey(olc::RIGHT).bHeld) { - vCamera.x+=8*fElapsedTime; - } - if (GetKey(olc::LEFT).bHeld) { - vCamera.x-=8*fElapsedTime; + pitch+=1*fElapsedTime; } vec3d vForward=Vector_Mul(vLookDir,8*fElapsedTime); if (GetKey(olc::W).bHeld) { @@ -508,7 +503,7 @@ public: matWorld=Matrix_MultiplyMatrix(matWorld,matTrans); vec3d vUp={0,1,0}; - vec3d vTarget={0,0,1}; + vec3d vTarget={0,sinf(pitch),cosf(pitch)}; mat4x4 matCameraRot=Matrix_MakeRotationY(fYaw); vLookDir=Matrix_MultiplyVector(matCameraRot,vTarget); vTarget=Vector_Add(vCamera,vLookDir);