Started with Camera class

This commit is contained in:
Riyyi
2015-03-19 00:55:59 +01:00
parent 996dd153a8
commit 7b8807b940
11 changed files with 139 additions and 24 deletions
+34 -9
View File
@@ -18,6 +18,9 @@ void MainGame::Initialize(sf::RenderWindow* window) {
this->map = new Map();
MapLoad mapLoad;
mapLoad.Load(this->map, "data/map/level1.json");
this->camera = new Camera();
this->camera->SetNewView(window);
}
void MainGame::Update(sf::RenderWindow* window) {
@@ -27,27 +30,49 @@ void MainGame::Update(sf::RenderWindow* window) {
if(inputManager.IsPressed(InputManager::Left)) {
std::cout << "LEFT" << std::endl;
this->entityManager->Get("test0")->velocity.x = -1;
this->entityManager->Get("test0")->velocity.x = -1.5;
this->camera->MoveCamera(window, sf::Vector2f(-1.5, 0));
}
if(inputManager.IsPressed(InputManager::Right)) {
std::cout << "RIGHT" << std::endl;
this->entityManager->Get("test0")->velocity.x = 1;
}
if(inputManager.IsPressed(InputManager::Down)) {
std::cout << "DOWN" << std::endl;
this->entityManager->Get("test0")->velocity.y = 1;
this->entityManager->Get("test0")->velocity.x = 1.5;
this->camera->MoveCamera(window, sf::Vector2f(1.5, 0));
}
if(inputManager.IsPressed(InputManager::Up)) {
std::cout << "UP" << std::endl;
this->entityManager->Get("test0")->velocity.y = -1;
this->entityManager->Get("test0")->velocity.y = -1.5;
this->camera->MoveCamera(window, sf::Vector2f(0, -1.5));
}
if(inputManager.IsPressed(InputManager::Down)) {
std::cout << "DOWN" << std::endl;
this->entityManager->Get("test0")->velocity.y = 1.5;
this->camera->MoveCamera(window, sf::Vector2f(0, 1.5));
}
if(inputManager.IsPressed(InputManager::Up)
&& inputManager.IsPressed(InputManager::Down)) {
this->entityManager->Get("test0")->velocity.x = 0;
this->entityManager->Get("test0")->velocity.y = 0;
}
if(inputManager.IsPressed(InputManager::Left)
&& inputManager.IsPressed(InputManager::Right)) {
this->entityManager->Get("test0")->velocity.x = 0;
this->entityManager->Get("test0")->velocity.y = 0;
}
// if(inputManager.IsPressed(InputManager::Up)
// && inputManager.IsPressed(InputManager::Right)) {
// this->entityManager->Get("test0")->velocity.y = -1.125;
// this->entityManager->Get("test0")->velocity.x = 1.125;
// }
this->entityManager->Update();
if(inputManager.IsPressed(InputManager::LoadMap)) {
+2
View File
@@ -7,6 +7,7 @@
#include "entitymanager.h"
#include "inputmanager.h"
#include "mapload.h"
#include "camera.h"
class MainGame : public GameState
{
@@ -19,6 +20,7 @@ public:
private:
EntityManager* entityManager;
Map* map;
Camera* camera;
};
#endif // MAINGAME_H