diff --git a/06-Students-Choice/SDLProject.xcodeproj/project.xcworkspace/xcuserdata/mkarroqe.xcuserdatad/UserInterfaceState.xcuserstate b/06-Students-Choice/SDLProject.xcodeproj/project.xcworkspace/xcuserdata/mkarroqe.xcuserdatad/UserInterfaceState.xcuserstate index 7ee00e9..20f052d 100644 Binary files a/06-Students-Choice/SDLProject.xcodeproj/project.xcworkspace/xcuserdata/mkarroqe.xcuserdatad/UserInterfaceState.xcuserstate and b/06-Students-Choice/SDLProject.xcodeproj/project.xcworkspace/xcuserdata/mkarroqe.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/06-Students-Choice/SDLProject/Entity.cpp b/06-Students-Choice/SDLProject/Entity.cpp index 1966ebb..1f7ba05 100644 --- a/06-Students-Choice/SDLProject/Entity.cpp +++ b/06-Students-Choice/SDLProject/Entity.cpp @@ -50,14 +50,6 @@ void Entity::Update(float deltaTime, Entity *snail, Entity *player, Entity *obje } } - modelMatrix = glm::mat4(1.0f); - modelMatrix = glm::translate(modelMatrix, position); - modelMatrix = glm::scale(modelMatrix, scale); - - modelMatrix = glm::rotate(modelMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - modelMatrix = glm::rotate(modelMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - modelMatrix = glm::rotate(modelMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); - if (entityType == ENEMY) { // something subtle here.. // rotation.z -= 0.5 * deltaTime; @@ -89,29 +81,35 @@ void Entity::Update(float deltaTime, Entity *snail, Entity *player, Entity *obje // if snail is near a plant, go the opposite way else if (previouslyCollided) { if (position.x < snail->position.x) { - position.x -= 1 * deltaTime; + position.x -= 0.41 * deltaTime; } else { - position.x += 1 * deltaTime; + position.x += 0.41 * deltaTime; } if (position.z < snail->position.z) { - position.z -= 1 * deltaTime; + position.z -= 0.41 * deltaTime; } else { - position.z += 1 * deltaTime; + position.z += 0.41 * deltaTime; } } // if you haven't collided before, live ur life, betta else { - position.x += 0;//rand() % 20 - 10; - position.y -= 0; //0.01; - position.z += 0; //rand() % 20 - 10; + position.x = 0;//rand() % 20 - 10; + position.y = 0; //0.01; + position.z = 0; //rand() % 20 - 10; } } - - } + + modelMatrix = glm::mat4(1.0f); + modelMatrix = glm::translate(modelMatrix, position); + modelMatrix = glm::scale(modelMatrix, scale); + + modelMatrix = glm::rotate(modelMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + modelMatrix = glm::rotate(modelMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + modelMatrix = glm::rotate(modelMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); } void Entity::Render(ShaderProgram *program) { diff --git a/06-Students-Choice/SDLProject/main.cpp b/06-Students-Choice/SDLProject/main.cpp index 1fc18bd..9a21ef0 100644 --- a/06-Students-Choice/SDLProject/main.cpp +++ b/06-Students-Choice/SDLProject/main.cpp @@ -393,6 +393,7 @@ void Update() { while (deltaTime >= FIXED_TIMESTEP) { currentScene->state.player->Update(FIXED_TIMESTEP, snail, currentScene->state.player, currentScene->state.objects, OBJECT_COUNT); + // TODO: uncomment // if (currentScene->state.objects[OBJECT_COUNT - 1].CheckCollision(¤tScene->state.enemies[0])) { // std::cout << "COLLISION\n"; // currentScene->state.player_lives -= 1;