/********************\ | Copyright 2024, | | Ulysse Cura | \********************/ //////////////////////////////////////////////////////////////////////// // // // Programme de la caméra, sert a avoir un rectangle et de pouvoir // // la gérer correctement en fonction de la taille de la map... etc... // // // //////////////////////////////////////////////////////////////////////// #ifndef CAMERA_HPP #define CAMERA_HPP #include // SDL_Rect #include "Game.hpp" // Game::... #include "TileMap.hpp" // TileMap::... #include "Vector2D.hpp" // Vector2D class struct Camera { Camera(int width, int height) { camR.w = width; camR.h = height; } // Update camera void update() { camR.x = static_cast(centerPos.x - (static_cast(camR.w) / 2.0f)); camR.y = static_cast(centerPos.y - (static_cast(camR.h) / 2.0f)); if(camR.x < 0) camR.x = 0; if(camR.y < 0) camR.y = 0; if(camR.x > Game::tileMap.worldWidth - camR.w) camR.x = Game::tileMap.worldWidth - camR.w; if(camR.y > Game::tileMap.worldHeight - camR.h) camR.y = Game::tileMap.worldHeight - camR.h; } Vector2D centerPos; SDL_Rect camR; }; #endif