CSC3224_Computer_Games_Development / Game / Game.cpp
Game.cpp
Raw
#include "Game.h"

Game::Game() : BaseGameEvents(new sf::RenderWindow(sf::VideoMode(1024, 768), "Game")){}

Game::~Game(){}

void Game::initializeGame()
{
	window->setFramerateLimit(60);
	// Load keys from file
	std::cout << "Loading keys" << std::endl;
	messageHandler.loadMessagesFromFile(KEY_MAPPING_DIR + std::string("KeyMap.txt"));
	// Dispaly the keybinings to the user
	messageHandler.printKeyMap();

	ShowSplashScreen(); // Game loaded - press any button

	auto platformConfig = EngineFileSystem::ReadFileToJson(GAME_LEVEL_DIR + std::string("platform.json"));

// Set up scene subsystemss
	this->scene->addSceneSystem(new PlayerControl(*this->scene, messageHandler));
	this->scene->addSceneSystem(new Score(*this->scene));


//	this->scene->addSceneSystem(new MovingCamera(*this->scene, window, platformConfig));
}
// Update Game and calculate fps
void Game::updateGame(sf::Time elapsedTime)
{	
	time += elapsedTime;
	std::stringstream messageOnScreen;
	fpsCounter = 1 / elapsedTime.asSeconds();
	scene->saveFPS(fpsCounter);

	messageOnScreen << "FPS: " << fpsCounter;
	if (time.asSeconds() > 1)
	{
		window->setTitle(messageOnScreen.str());
		time = sf::Time::Zero;
	}
}

void Game::quitGame(){}