Skip to content

Commit

Permalink
betta leaves u alone until you hide for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarroqe committed May 12, 2020
1 parent 3f1efaa commit c7b675a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
Binary file not shown.
32 changes: 15 additions & 17 deletions 06-Students-Choice/SDLProject/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions 06-Students-Choice/SDLProject/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(&currentScene->state.enemies[0])) {
// std::cout << "COLLISION\n";
// currentScene->state.player_lives -= 1;
Expand Down

0 comments on commit c7b675a

Please sign in to comment.