Skip to content

Commit

Permalink
Add bounding box to zombie and rocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoudaboueleneen committed Dec 4, 2023
1 parent 15ec50e commit 27b498a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions OpenGLMeshLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ GLdouble playerAngle = 0;
// Rocks
Model_3DS model_rocks;
Vector rocksPosition(20, 0, 32);
Vector rockBoundingBoxOffset = Vector(-3, 0, -7); // Offset to move the bounding box closer to the model
BoundingBox rocksBoundingBox(rocksPosition - Vector(1, 1, 1) + rockBoundingBoxOffset, rocksPosition + Vector(10, 10, 10) + rockBoundingBoxOffset);

// Tree
Model_3DS model_tree;
Expand All @@ -126,8 +128,8 @@ GLdouble zombieAngle = 0;
// Jeep
Model_3DS model_jeep;
Vector jeepPosition(25, 7, -25);
float jeepBoundingBoxOffsetZ = 8; // Define the offset in the positive z direction to move the bounding box closer to the jeep
BoundingBox jeepBoundingBox(jeepPosition - Vector(0.5, 10, 2) + Vector(0, 0, jeepBoundingBoxOffsetZ), jeepPosition + Vector(10, 10, 17) + Vector(0, 0, jeepBoundingBoxOffsetZ));
Vector jeepBoundingBoxOffset = Vector(0, 0, 8); // Offset to move the bounding box closer to the model
BoundingBox jeepBoundingBox(jeepPosition - Vector(0.5, 10, 2) + jeepBoundingBoxOffset, jeepPosition + Vector(10, 10, 17) + jeepBoundingBoxOffset);

// Fence
Model_3DS model_fence;
Expand Down Expand Up @@ -379,6 +381,7 @@ void DisplayGame(void) {
drawBoundingBox(playerBoundingBox);
drawBoundingBox(jeepBoundingBox);
drawBoundingBox(zombieBoundingBox);
drawBoundingBox(rocksBoundingBox);

// Draw Time
/*
Expand Down Expand Up @@ -631,6 +634,9 @@ void Update() {
else if (playerBoundingBox.intersects(zombieBoundingBox)) {
playerPosition = previousPlayerPosition;
}
else if (playerBoundingBox.intersects(rocksBoundingBox)) {
playerPosition = previousPlayerPosition;
}

// Update camera to follow player
if (cameraMode == THIRD_PERSON) {
Expand Down

0 comments on commit 27b498a

Please sign in to comment.