ouverture de fenetre possible

faire le Game::run
This commit is contained in:
YANNIS
2025-05-29 18:25:10 +02:00
parent bd9bc5e2e2
commit 62a0b9719f
10 changed files with 91 additions and 68 deletions
+38
View File
@@ -0,0 +1,38 @@
#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();
}