Skip to content

Commit

Permalink
better betta follow/ignore behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarroqe committed May 12, 2020
1 parent e554097 commit 273e9ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Binary file not shown.
26 changes: 18 additions & 8 deletions 06-Students-Choice/SDLProject/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,34 @@ void Entity::Update(float deltaTime, Entity *snail, Entity *player, Entity *obje
// if snail is not near plant, follow
if (!(objects[i].CheckCollision(snail))) {
if (position.x < snail->position.x) {
position.x += 1 * deltaTime;
position.x += 0.1 * deltaTime;
}
else {
position.x -= 1 * deltaTime;
position.x -= 0.1 * deltaTime;
}

if (position.z < snail->position.x) {
position.z += 1 * deltaTime;
if (position.z < snail->position.z) {
position.z += 0.1 * deltaTime;
}
else {
position.z -= 1 * deltaTime;
position.z -= 0.1 * deltaTime;
}
}
// if snail is near a plant, go the opposite way TODO: check this makes sense
else {
rotation.z += 360 * deltaTime;
position.x -= 1 * deltaTime;
position.z -= 1 * deltaTime;
if (position.x < snail->position.x) {
position.x -= 1 * deltaTime;
}
else {
position.x += 1 * deltaTime;
}

if (position.z < snail->position.z) {
position.z -= 1 * deltaTime;
}
else {
position.z += 1 * deltaTime;
}
}
}

Expand Down

0 comments on commit 273e9ef

Please sign in to comment.