Camera tracks center

This commit is contained in:
COW_ILLUMINATI 2024-05-01 18:34:09 -04:00
parent 77a4939cce
commit 3f10426679
2 changed files with 8 additions and 6 deletions

@ -1,3 +1,3 @@
0.1 0.01
150 200
0 0

@ -412,8 +412,9 @@ int main() {
std::clock_t prevClock = startTime; std::clock_t prevClock = startTime;
bool pushframe = false; bool pushframe = false;
// Camera will be centered on this star // Camera will be centered on these stars
int trackedStar = 0; int trackedStarA = 0;
int trackedStarB = 1;
// Initialize the camera position // Initialize the camera position
Vector3 cameraPosition = Vector3(0,0,0); Vector3 cameraPosition = Vector3(0,0,0);
@ -499,7 +500,7 @@ int main() {
} }
// New position // New position
cameraPosition = stars[trackedStar].position; cameraPosition = (stars[trackedStarA].position + stars[trackedStarB].position)/2;
// Pushes the frame // Pushes the frame
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@ -546,7 +547,8 @@ int main() {
playing = !playing; playing = !playing;
break; break;
case SDLK_RETURN: case SDLK_RETURN:
trackedStar = rand() % starCount; trackedStarA = rand() % starCount;
trackedStarB = trackedStarA;
break; break;
} }
break; break;