本文整理汇总了C++中SDL_ShowSimpleMessageBox函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_ShowSimpleMessageBox函数的具体用法?C++ SDL_ShowSimpleMessageBox怎么用?C++ SDL_ShowSimpleMessageBox使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_ShowSimpleMessageBox函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_GL_SetAttribute
void CGame::IniciandoVideo()
{
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Video Init: ", (const char *)SDL_GetError(), NULL);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
window = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH_SCREEN, HEIGHT_SCREEN, SDL_WINDOW_OPENGL);
if (!window) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Windows OpenGL Init: ", (const char *)SDL_GetError(), NULL);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
}
gContext = SDL_GL_CreateContext(window);
if (!gContext) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Context Init: ", (const char *)SDL_GetError(), NULL);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
}
openGlImplement.setSDLWindow(window);
}
示例2: SDL_ShowSimpleMessageBox
bool Game::SpriteCollision(Sprite* pSpriteHitter, Sprite* pSpriteHittee){
GameEngine *pGameEngine = GameEngine::GetEngine();
// See if the chicken was hit
if (pSpriteHittee == _pChickenSprite)
{
// Move the chicken back to the start
_pChickenSprite->SetPosition(4, 175);
// See if the game is over
if (--_iNumLives > 0)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION ,
"Henway",
"Ouch!",
pGameEngine->GetWindow());
else
{
// Display game over message
char szText[64];
sprintf(szText, "Game Over! You scored %d points.", _iScore);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION ,
"Henway",
szText,
pGameEngine->GetWindow());
_bGameOver = true;
}
return false;
}
return true;
}
示例3: _FAIL
void _FAIL(int line = -1)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "FAIL", "SOMETHING WENT WRONG!!!!", 0);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "FAIL", SDL_GetError(), 0);
char str[32];
sprintf(str, "line: %d", line);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "FAIL", str, 0);
raise(SIGINT); //break into debugger
}
示例4: defined
int SteamGlobal::init()
{
#if defined(CHOWDREN_FORCE_STEAM_OPEN) && defined(CHOWDREN_STEAM_APPID)
if (SteamAPI_RestartAppIfNecessary(CHOWDREN_STEAM_APPID)) {
return EXIT_FAILURE;
}
#endif
initialized = SteamAPI_Init();
if (!initialized) {
std::cout << "Could not initialize Steam API" << std::endl;
#ifdef CHOWDREN_FORCE_STEAM_OPEN
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Steam error",
"Could not initialize Steam API. "
"Please make sure you are logged in to Steam "
"before opening the game.",
NULL);
return EXIT_FAILURE;
#endif
return 0;
}
std::cout << "Initialized Steam API" << std::endl;
bool debug_achievements = getenv("CHOWDREN_DEBUG_ACHIEVEMENTS") != NULL;
if (debug_achievements) {
if (!SteamUserStats()->ResetAllStats(true))
std::cout << "Could not reset stats" << std::endl;
}
if (!SteamUserStats()->RequestCurrentStats())
std::cout << "Could not request Steam stats" << std::endl;
#ifdef CHOWDREN_STEAM_APPID
ISteamApps * ownapp = SteamApps();
if (!ownapp->BIsSubscribedApp(CHOWDREN_STEAM_APPID)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Steam error",
"Please purchase the Steam version of the "
"game if you want to play it on Steam.",
NULL);
return EXIT_FAILURE;
}
#endif
steam_language = SteamApps()->GetCurrentGameLanguage();
if (steam_language.empty())
steam_language = "english";
steam_language[0] = toupper(steam_language[0]);
std::cout << "Detected Steam language: " << steam_language << std::endl;
return 0;
}
示例5: main
int main(int argc, char* args[])
{
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
//This is a nice alternative to printf in SDL 2
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SDL", "SDL failed to initialize!", NULL);
SDL_Quit();
return 0;
}
//In SDL 2, SDL_SetVideoMode has been removed, we now create windows using SDL_CreateWindow to create windows
Window = SDL_CreateWindow("I can talk!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);
//SDL_GetWindowSurface gets the backbuffer of the window we created with SDL_CreateWindow
Backbuffer = SDL_GetWindowSurface(Window);
if(!LoadFiles())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SDL", SDL_GetError(), NULL);
//SDL_DestroyWindow destroys a window we created with SDL_CreateWindow
SDL_DestroyWindow(Window);
FreeFiles();
SDL_Quit();
return 0;
}
while(ProgramIsRunning())
{
DrawImage(Background,Backbuffer, 0, 0);
DrawRasterText(FontImage, Backbuffer, "All Systems Go!" , 100, 100, charSize);
DrawRasterText(FontImage, Backbuffer, "Drawing Fonts is Fun!", 100, 116, charSize);
SDL_Delay(20);
//In SDL 2, SDL_UpdateWindowSurface replaces SDL_Flip
SDL_UpdateWindowSurface(Window);
}
FreeFiles();
//SDL_DestroyWindow destroys a window we created with SDL_CreateWindow
SDL_DestroyWindow(Window);
SDL_Quit();
return 0;
}
示例6: playsound
void playsound (short sound, Mix_Chunk* gSound)
{
//Load sfx
switch (sound)
{
case 1 :
gSound = Mix_LoadWAV ( SONYEP );
break;
case 2 :
gSound = Mix_LoadWAV ( SONNOP );
break;
case 3 :
gSound = Mix_LoadWAV ( SONCLICBOUTON );
break;
case 4 : //son defaite
gSound = Mix_LoadWAV (SONLOOSE);
break;
}
if ( gSound == NULL )
{
SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_ERROR, "Erreur du gestionnaire de son", Mix_GetError() , NULL);
exit (EXIT_FAILURE);
}
Mix_PlayChannel ( -1, gSound, 0 );
return;
}
示例7: fatalError
void
fatalError(const char *string)
{
printf("%s: %s\n", string, SDL_GetError());
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, string, SDL_GetError(), NULL);
exit(1);
}
示例8: main
int main(int argc, char* argv[])
{
/* Unused arguments */
(void)argc;
(void)argv;
/* Initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) != 0){
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"SDL_Init Failure",
SDL_GetError(),
NULL);
return EXIT_FAILURE;
}
/* Initialize game state */
init_game();
/* Initialize graphics */
if (init_graphics() != 0){
return EXIT_FAILURE;
}
/* Start game logic thread */
SDL_CreateThread(game_thread, "GameLogic", NULL);
/* Main Loop */
while (!quit){
/* Handle events*/
handle_event();
/* Render graphics */
update_graphics();
}
return EXIT_SUCCESS;
}
示例9: SDL_VERSION
void SDLWindow::Alert (const char* message, const char* title) {
#ifdef HX_WINDOWS
int count = 0;
int speed = 0;
bool stopOnForeground = true;
SDL_SysWMinfo info;
SDL_VERSION (&info.version);
SDL_GetWindowWMInfo (sdlWindow, &info);
FLASHWINFO fi;
fi.cbSize = sizeof (FLASHWINFO);
fi.hwnd = info.info.win.window;
fi.dwFlags = stopOnForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
fi.uCount = count;
fi.dwTimeout = speed;
FlashWindowEx (&fi);
#endif
if (message) {
SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, title, message, sdlWindow);
}
}
示例10: convertMessageBoxType
bool Window::showMessageBox(const std::string &title, const std::string &message, MessageBoxType type, bool attachtowindow)
{
SDL_MessageBoxFlags flags = convertMessageBoxType(type);
SDL_Window *sdlwindow = attachtowindow ? window : nullptr;
return SDL_ShowSimpleMessageBox(flags, title.c_str(), message.c_str(), sdlwindow) >= 0;
}
示例11: SDL_ShowSimpleMessageBox
void EngineRoutines::ShowSimpleMsg(const char* msg)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"notice",
msg,
NULL);
}
示例12: IMG_Load
SDL_Texture *get_texture_from_image(SDL_Renderer *pRenderer, const char *filepath) {
/** Generate an SDL_Texture object from an image filepath. **/
SDL_Surface *image_surface = IMG_Load(filepath);
if (image_surface == NULL) {
/** Display an error message and quit the programme in case of error. **/
char *message=calloc(256,sizeof(char)) ;
sprintf(message,"Failed to load image %s!\n%s",filepath,SDL_GetError()) ;
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error image loading", message ,NULL) ;
free(message) ;
#ifdef DEBUG
fprintf(stdout,"image_surface error (%s)\n",SDL_GetError());
#endif
exit(EXIT_FAILURE) ;
}
SDL_Texture *image_texture = SDL_CreateTextureFromSurface(pRenderer,image_surface) ;
if (image_texture == NULL) {
/** Exit the programme in case of error. **/
exit(EXIT_FAILURE) ;
}
SDL_FreeSurface(image_surface) ; /** We clean up the surface. **/
return image_texture ;
}
示例13: show_add_player_input_message
void show_add_player_input_message(SDL_Window *window)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION,
"Adicionar Jogador",
"Insira os dados do jogador no terminal.",
window);
}
示例14: SDL_ShowSimpleMessageBox
void GameEngine::ErrorQuit(char* szErrorMsg)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Critical Error",
szErrorMsg,
GetWindow());
}
示例15: show_add_player_message
/*
* Série de três funções que mostram janelas popup quando
* inserimos um jogador (opção da tecla <a>)
*/
void show_add_player_message(SDL_Window *window)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION,
"Adicionar Jogador",
"Clique num lugar vazio para inserir um novo jogador.",
window);
}