diff --git a/Debug/grk-cw9.exe b/Debug/grk-cw9.exe index a0f1aca..615018c 100644 Binary files a/Debug/grk-cw9.exe and b/Debug/grk-cw9.exe differ diff --git a/Debug/grk-cw9.pdb b/Debug/grk-cw9.pdb index b84bd90..e15326c 100644 Binary files a/Debug/grk-cw9.pdb and b/Debug/grk-cw9.pdb differ diff --git a/cw 9/Debug/Box.obj b/cw 9/Debug/Box.obj index a975630..d3b85a4 100644 Binary files a/cw 9/Debug/Box.obj and b/cw 9/Debug/Box.obj differ diff --git a/cw 9/Debug/Camera.obj b/cw 9/Debug/Camera.obj index d1eca6d..a2dac95 100644 Binary files a/cw 9/Debug/Camera.obj and b/cw 9/Debug/Camera.obj differ diff --git a/cw 9/Debug/Laser.obj b/cw 9/Debug/Laser.obj index 9561cfd..b1f9a79 100644 Binary files a/cw 9/Debug/Laser.obj and b/cw 9/Debug/Laser.obj differ diff --git a/cw 9/Debug/Render_Utils.obj b/cw 9/Debug/Render_Utils.obj index 7aba8f2..458482f 100644 Binary files a/cw 9/Debug/Render_Utils.obj and b/cw 9/Debug/Render_Utils.obj differ diff --git a/cw 9/Debug/SOIL.obj b/cw 9/Debug/SOIL.obj index 4330496..017cecb 100644 Binary files a/cw 9/Debug/SOIL.obj and b/cw 9/Debug/SOIL.obj differ diff --git a/cw 9/Debug/Shader_Loader.obj b/cw 9/Debug/Shader_Loader.obj index 0c7c8fc..d189d4b 100644 Binary files a/cw 9/Debug/Shader_Loader.obj and b/cw 9/Debug/Shader_Loader.obj differ diff --git a/cw 9/Debug/SpaceShip.obj b/cw 9/Debug/SpaceShip.obj index 02d7f20..62d4890 100644 Binary files a/cw 9/Debug/SpaceShip.obj and b/cw 9/Debug/SpaceShip.obj differ diff --git a/cw 9/Debug/Texture.obj b/cw 9/Debug/Texture.obj index bf02be8..2ff0583 100644 Binary files a/cw 9/Debug/Texture.obj and b/cw 9/Debug/Texture.obj differ diff --git a/cw 9/Debug/grk-cw9.exe.recipe b/cw 9/Debug/grk-cw9.exe.recipe index 87950e8..e1898f4 100644 --- a/cw 9/Debug/grk-cw9.exe.recipe +++ b/cw 9/Debug/grk-cw9.exe.recipe @@ -2,7 +2,7 @@ - C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe + C:\Users\Serhii\source\repos\grk_game_scene\Debug\grk-cw9.exe diff --git a/cw 9/Debug/grk-cw9.log b/cw 9/Debug/grk-cw9.log index 841f56c..b29002f 100644 --- a/cw 9/Debug/grk-cw9.log +++ b/cw 9/Debug/grk-cw9.log @@ -1,48 +1,48 @@  main.cpp -C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition -C:\Users\arciom\Desktop\GRK_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(124,30): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(166,38): warning C4305: '=': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(189,16): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(230,20): warning C4018: '<': signed/unsigned mismatch -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(266,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(280,98): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition +C:\Users\Serhii\source\repos\grk_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(124,30): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(168,38): warning C4305: '=': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(191,16): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(232,20): warning C4018: '<': signed/unsigned mismatch +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(268,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(282,98): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(283,68): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(285,68): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(317,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(372,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(381,108): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(319,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(374,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(383,108): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(389,87): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(391,87): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(389,223): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(392,59): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(391,223): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(394,59): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(393,37): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(428,2): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(434,20): warning C4018: '<': signed/unsigned mismatch -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(439,50): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(440,51): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(512,21): warning C4018: '<': signed/unsigned mismatch -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(514,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(669,21): warning C4305: '-=': truncation from 'double' to 'float' -C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(671,21): warning C4305: '+=': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(395,37): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(430,2): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(436,20): warning C4018: '<': signed/unsigned mismatch +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(441,50): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(442,51): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(520,21): warning C4018: '<': signed/unsigned mismatch +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(522,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(726,21): warning C4305: '-=': truncation from 'double' to 'float' +C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(728,21): warning C4305: '+=': truncation from 'double' to 'float' Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library - grk-cw9.vcxproj -> C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe + grk-cw9.vcxproj -> C:\Users\Serhii\source\repos\grk_game_scene\Debug\grk-cw9.exe diff --git a/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog index 965627e..ebe3aef 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog index 2b3cb78..13da725 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog index 623a1b0..c7756f7 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate b/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate index 253b6db..dc00425 100644 --- a/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate +++ b/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate @@ -1,2 +1,2 @@ -PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:TargetPlatformVersion=10.0.22000.0: -Debug|Win32|C:\Users\arciom\Desktop\GRK_game_scene\| +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: +Debug|Win32|C:\Users\Serhii\source\repos\grk_game_scene\| diff --git a/cw 9/Debug/grk-cw9.tlog/link.command.1.tlog b/cw 9/Debug/grk-cw9.tlog/link.command.1.tlog index f15f006..be7dce5 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/link.command.1.tlog and b/cw 9/Debug/grk-cw9.tlog/link.command.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog b/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog index e6d8cb5..5c1bd22 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog and b/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog b/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog index 17d7dbb..aa10d29 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog and b/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog differ diff --git a/cw 9/Debug/image_DXT.obj b/cw 9/Debug/image_DXT.obj index 80ef900..1369428 100644 Binary files a/cw 9/Debug/image_DXT.obj and b/cw 9/Debug/image_DXT.obj differ diff --git a/cw 9/Debug/image_helper.obj b/cw 9/Debug/image_helper.obj index f73a11d..4b21e18 100644 Binary files a/cw 9/Debug/image_helper.obj and b/cw 9/Debug/image_helper.obj differ diff --git a/cw 9/Debug/main.obj b/cw 9/Debug/main.obj index 4ad2b11..53d118a 100644 Binary files a/cw 9/Debug/main.obj and b/cw 9/Debug/main.obj differ diff --git a/cw 9/Debug/stb_image_aug.obj b/cw 9/Debug/stb_image_aug.obj index 217cc07..bb6c7dd 100644 Binary files a/cw 9/Debug/stb_image_aug.obj and b/cw 9/Debug/stb_image_aug.obj differ diff --git a/cw 9/Debug/vc142.idb b/cw 9/Debug/vc142.idb index bdb08d5..acf0e53 100644 Binary files a/cw 9/Debug/vc142.idb and b/cw 9/Debug/vc142.idb differ diff --git a/cw 9/Debug/vc142.pdb b/cw 9/Debug/vc142.pdb index 66fd8c3..076768f 100644 Binary files a/cw 9/Debug/vc142.pdb and b/cw 9/Debug/vc142.pdb differ diff --git a/cw 9/src/SpaceShip.cpp b/cw 9/src/SpaceShip.cpp index 2df3925..7ed9531 100644 --- a/cw 9/src/SpaceShip.cpp +++ b/cw 9/src/SpaceShip.cpp @@ -19,7 +19,7 @@ SpaceShip::SpaceShip(int numberOfLasers) { gun.reserve(maxNumberOfLasers); this->spaceShipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f); - this->spaceShipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f); + this->spaceShipPos = glm::vec3(0.065808f, 1.250000f, -2.0); for (int i = 0; i < maxNumberOfLasers; i++) { gun.push_back(Laser(this->spaceShipDir, this->spaceShipPos, 0.01, false)); diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index c0a766b..fec0c2e 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -11,7 +11,7 @@ #include "Laser.h" #include "SpaceShip.h" - +#include #include "Box.cpp" #include #include @@ -156,6 +156,8 @@ std::vector lasersLightPos{ laserLightPos0, laserLightPos1, laserLigh std::vector lasers; + + void updateDeltaTime(float time) { if (lastTime < 0) { lastTime = time; @@ -422,7 +424,7 @@ void renderScene(GLFWwindow* window) // glm::vec3(0.3, 0.3, 0.5) // ); drawObjectPBR(shipContext, - glm::translate(spaceShip.getSpaceShipPos()) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::scale(glm::vec3(0.03f)), + glm::translate(spaceShip.getSpaceShipPos()) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::scale(glm::vec3(0.015f)), glm::vec3(0.3, 0.3, 0.5), 0.2, 1.0 ); @@ -442,6 +444,12 @@ void renderScene(GLFWwindow* window) } + /*std::cout << spaceShip.getSpaceShipPos().x << std::endl; + std::cout << spaceShip.getSpaceShipPos().y << std::endl;*/ + //std::cout << spaceShip.getSpaceShipPos().z << std::endl; + + + //test depth buffer /*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(programTest); @@ -527,6 +535,8 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) } + + void init(GLFWwindow* window) { glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); @@ -592,7 +602,18 @@ void shutdown(GLFWwindow* window) shaderLoader.DeleteProgram(program); } +bool check_room_collision(int plus_or_minus) { + glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f); + float moveSpeed = 0.02f * deltaTime * 60; + glm::vec3 spaceShipPos = spaceShip.getSpaceShipPos() + (spaceShip.getSpaceShipDir() * moveSpeed) * plus_or_minus; + + bool collision = spaceShipPos.z < -2.04 || spaceShipPos.z > 2.06 || + spaceShipPos.x < -1.61 || spaceShipPos.x > 1.59 || + spaceShipPos.y > 2.15 || spaceShipPos.y < 0.11; + + return collision; +} //obsluga wejscia void processInput(GLFWwindow* window) @@ -603,37 +624,61 @@ void processInput(GLFWwindow* window) glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceShip.getSpaceShipDir(), glm::vec3(0.f, 1.f, 0.f))); glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f); float angleSpeed = 0.05f * deltaTime * 60; - float moveSpeed = 0.05f * deltaTime * 60; + float moveSpeed = 0.02f * deltaTime * 60; + + if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(window, true); } if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) { + if (!check_room_collision(1)) { + spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceShip.getSpaceShipDir() * moveSpeed); + } //spaceshipPos += spaceshipDir * moveSpeed; - spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceShip.getSpaceShipDir() * moveSpeed); + } if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) { + if (!check_room_collision(-1)) { + spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceShip.getSpaceShipDir() * moveSpeed); + } //spaceshipPos -= spaceshipDir * moveSpeed; - spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceShip.getSpaceShipDir() * moveSpeed); + } if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) { //spaceshipPos += spaceshipSide * moveSpeed; + if (!check_room_collision(1)) { + spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceshipSide * moveSpeed); + } - spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceshipSide * moveSpeed); + } if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) { + if (!check_room_collision(-1)) { + spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceshipSide * moveSpeed); + } + //spaceshipPos -= spaceshipSide * moveSpeed; - spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceshipSide * moveSpeed); + } if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) { //spaceshipPos += spaceshipUp * moveSpeed; + if ((spaceShip.getSpaceShipPos() + spaceshipUp * moveSpeed).y > 2.25) { + std::cout << "Collision detected!" << std::endl; + } + else{ + spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceshipUp * moveSpeed); + } - spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceshipUp * moveSpeed); } if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS) { - //spaceshipPos -= spaceshipUp * moveSpeed; + if ((spaceShip.getSpaceShipPos() + spaceshipUp * moveSpeed).y < 0.05) { + std::cout << "Collision detected!" << std::endl; + } + else { + spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceshipUp * moveSpeed); + } - spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceshipUp * moveSpeed); } if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) { //spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceShip.getSpaceShipDir(), 0));