Player updates, Camera updates

Player update: Framerate independent movement
Camera update: Move over camera movement to Camera class
This commit is contained in:
Riyyi
2015-03-21 15:19:47 +01:00
parent ad6b1bf9c5
commit 129236788f
6 changed files with 110 additions and 106 deletions
+7 -3
View File
@@ -21,8 +21,7 @@ void MainGame::Initialize(sf::RenderWindow* window) {
mapLoad.Load(this->map, "data/map/level1.json");
// Load Camera
this->camera = new Camera();
this->camera->SetNewView(window);
this->camera = new Camera(window);
// Load Player
this->player = new Player(this->entityManager, this->map, this->camera, 100, 100);
@@ -30,8 +29,13 @@ void MainGame::Initialize(sf::RenderWindow* window) {
}
void MainGame::Update(sf::RenderWindow* window) {
this->player->Update(window, inputManager);
this->time = this->clock.getElapsedTime();
int timeElapsed = this->time.asMicroseconds();
this->clock.restart();
this->player->Update(window, inputManager, timeElapsed);
this->entityManager->Update();
this->camera->Update(window, this->map, sf::Vector2f(this->player->getPosition().x, this->player->getPosition().y));
if(inputManager.IsPressed(InputManager::LoadMap)) {
std::cout << "Loading Map..." << std::endl;
+3
View File
@@ -19,6 +19,9 @@ public:
void Destroy(sf::RenderWindow* window);
private:
sf::Clock clock;
sf::Time time;
EntityManager* entityManager;
Map* map;
Camera* camera;