1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Implementa bloco try/catch em Game

This commit is contained in:
Danilo 2024-05-28 14:43:56 -03:00
parent 6a48d6d664
commit f8b7f7abd6
2 changed files with 12 additions and 10 deletions

View File

@ -68,14 +68,19 @@ namespace xna {
} }
int Game::Run() { int Game::Run() {
Initialize(); try {
Initialize();
if (graphicsDevice == nullptr) { if (graphicsDevice == nullptr) {
MessageBox(nullptr, "O dispositivo gráfico não foi inicializado corretamente", "XN65", MB_OK); MessageBox(nullptr, "O dispositivo gráfico não foi inicializado corretamente", "XN65", MB_OK);
return EXIT_FAILURE; return EXIT_FAILURE;
}
return StartGameLoop();
} }
catch (std::exception& e) {
return StartGameLoop(); MessageBox(nullptr, e.what(), "XN65", MB_OK);
}
} }
void Game::Initialize() { void Game::Initialize() {

View File

@ -25,10 +25,7 @@ namespace xna {
} }
void LoadContent() override { void LoadContent() override {
spriteBatch = New<SpriteBatch>(*graphicsDevice); spriteBatch = New<SpriteBatch>(*graphicsDevice);
auto effect = Content()->Load<PSoundEffect>("ExitReached");
Game::LoadContent(); Game::LoadContent();
} }