#ifndef _GKGAME_H
#define _GKGAME_H

#include "Rect.h"
#include "Point.h"
#include "Node.h"
#include "Scene.h"
#include <stack>

namespace PixelKit
{
	class Game
	{
	public:
		/*!
		 * @brief Game Constructor. Create a new game director object.
		 * @param title Game's title, used for the window chrome.
		 * @param xSize Game's window width.
		 * @param ySize Game's window height.
		 */
		Game(const char *title, int xSize, int ySize);
		
		/*!
		 * @brief Game destructor.
		 */
		~Game();
		
		/*!
		 * @brief Start the game on a Scene.
		 * @param scene Game's first scene.
		 */
		virtual void run(Scene* scene);
		
		/*!
		 * @brief Change the game's fullscreen state
		 */
		virtual void toggleFullScreen();
		
		/*!
		 * @brief Add a new PKScene on top of the stack and start rendering it
		 * @param scene PKScene to render next.
		 */
		virtual void pushScene(Scene* scene);
		
		/*!
		 * @brief Remove the current scene from the rendering stack. The scene below it will take
		 * input.
		 */
		virtual void popScene();
		
		/*!
		 * @brief Returns a pointer to the current scene (on top of the stack).
		 */
		virtual Scene* currentScene();
		
		/*!
		 * @brief Quit game by destroying all scenes and releasing all memory.
		 */
		virtual void quit();
		
		/*!
		 * @brief Game's window
		 */
		SDL_Window *window;
		
		/*!
		 * @brief Game's SDL_Renderer used to render to the window.
		 */
		SDL_Renderer *renderer;
	
	private:
		void initSDL();
		int intervalSinceLastFrame();
		void _pop();
		
		bool _shouldPop;
		bool _running;
		int _lastFrame;
		std::stack<Scene*> _sceneStack;
		std::string _title;
		bool _fullscreen;
	};
}

#endif