#include "Game.hpp"

Game::Game(){

	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		throw std::runtime_error("SDL could not initialize! SDL_Error: " + \
					std::string(SDL_GetError()));
	}

	window = SDL_CreateWindow("Bomberman", \
				SDL_WINDOWPOS_CENTERED, \
				SDL_WINDOWPOS_CENTERED, \
				800, 600, \
				SDL_WINDOW_SHOWN);
	if (window == nullptr) {
		throw std::runtime_error("Window could not be created! SDL_Error: " + \
					std::string(SDL_GetError()));
	}

	renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
	if (renderer == nullptr) {
		SDL_DestroyWindow(window);
		throw std::runtime_error("Renderer could not be created! SDL_Error: " + \
					std::string(SDL_GetError()));
	}

	isRunning = true;
}

Game::~Game() {
	if (renderer) {
		SDL_DestroyRenderer(renderer);
	}
	if (window) {
		SDL_DestroyWindow(window);
	}
	SDL_Quit();
}
