int MainMenu::DrawMenu(SDL_Surface *screen) { Play igra; SDL_FillRect(screen , NULL , 0x000000); txtRect3.x = HEIGHT/2 - 100; txtRect3.y = WIDTH/2 - 295; font3 = TTF_OpenFont("./font/42852.ttf",20); imgTxt3 = TTF_RenderText_Solid( font3 , "Текущий игрок: " , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.x = HEIGHT/2 + 50; imgTxt3 = TTF_RenderText_Solid( font3 , name , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.x = HEIGHT/2 - 100; txtRect3.y = WIDTH/2 - 200; font3 = TTF_OpenFont("./font/42852.ttf",25); imgTxt3 = TTF_RenderText_Solid( font3 , "Начало игры" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); Draw_Rect(screen, txtRect3.x - 10, txtRect3.y , 285, 25, 0xFFFFFF); txtRect3.y = WIDTH/2 - 175; imgTxt3 = TTF_RenderText_Solid( font3 , "Смена игрока" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 150; imgTxt3 = TTF_RenderText_Solid( font3 , "Просмотр результатов" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 125; imgTxt3 = TTF_RenderText_Solid( font3 , "Правила игры" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 100; imgTxt3 = TTF_RenderText_Solid( font3 , "Выход" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); SDL_Flip(screen); j3=0; txtRect3.y = WIDTH/2 - 200; while(end3 == 0) { while(SDL_PollEvent(&event3)) { switch(event3.type) { case SDL_MOUSEBUTTONDOWN: { if(event3.button.x >= HEIGHT/2 - 100 && event3.button.x <= HEIGHT/2 + 185) { if(event3.button.y >= WIDTH/2 - 200 && event3.button.y < WIDTH/2 - 175) /*играть*/ { igra.Game(screen); return 0; } if(event3.button.y >= WIDTH/2 - 175 && event3.button.y < WIDTH/2 - 150) /*смена имени*/ { while(name[i3]!='\0') name[i3++] = '\0'; Zastavka2(screen); return 0; } if(event3.button.y >= WIDTH/2 - 150 && event3.button.y < WIDTH/2 - 125) { Tablitca(screen); return 0; } if(event3.button.y >= WIDTH/2 - 125 && event3.button.y < WIDTH/2 - 100)/*правила игры*/ { PravilaGame(screen); return 0; } if(event3.button.y >= WIDTH/2 - 100 && event3.button.y < WIDTH/2 - 75) end3 = 1; } break; } case SDL_KEYDOWN: { if(event3.key.keysym.sym == SDLK_DOWN && j3 != 4) { if(j3<4) j3++; Draw_Rect(screen, txtRect3.x - 10, txtRect3.y , 285, 25, 0x000000); if(j3==0) txtRect3.y = WIDTH/2 - 200; else if(j3==1) { imgTxt3 = TTF_RenderText_Solid( font3 , "Начало игры" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 175; imgTxt3 = TTF_RenderText_Solid( font3 , "Смена игрока" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } else if(j3==2) { imgTxt3 = TTF_RenderText_Solid( font3 , "Смена игрока" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 150; imgTxt3 = TTF_RenderText_Solid( font3 , "Просмотр результатов" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } else if(j3==3) { imgTxt3 = TTF_RenderText_Solid( font3 , "Просмотр результатов" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 125; imgTxt3 = TTF_RenderText_Solid( font3 , "Правила игры" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } else if(j3==4) { imgTxt3 = TTF_RenderText_Solid( font3 , "Правила игры" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 100; imgTxt3 = TTF_RenderText_Solid( font3 , "Выход" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } Draw_Rect(screen, txtRect3.x - 10, txtRect3.y , 285, 25, 0xFFFFFF); SDL_Flip(screen); } if(event3.key.keysym.sym == SDLK_UP && j3 != 0) { if(j3>0) j3--; Draw_Rect(screen, txtRect3.x - 10, txtRect3.y , 285, 25, 0x000000); if(j3==0) { imgTxt3 = TTF_RenderText_Solid( font3 , "Смена игрока" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 200; imgTxt3 = TTF_RenderText_Solid( font3 , "Начало игры" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } else if(j3==1) { imgTxt3 = TTF_RenderText_Solid( font3 , "Просмотр результатов" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 175; imgTxt3 = TTF_RenderText_Solid( font3 , "Смена игрока" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } else if(j3==2) { imgTxt3 = TTF_RenderText_Solid( font3 , "Правила игры" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 150; imgTxt3 = TTF_RenderText_Solid( font3 , "Просмотр результатов" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } else if(j3==3) { imgTxt3 = TTF_RenderText_Solid( font3 , "Выход" , Color3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); txtRect3.y = WIDTH/2 - 125; imgTxt3 = TTF_RenderText_Solid( font3 , "Правила игры" , menucolor3 ); SDL_BlitSurface( imgTxt3 , NULL , screen , &txtRect3 ); } else if(j3==4) txtRect3.y = WIDTH/2 - 100; Draw_Rect(screen, txtRect3.x - 10, txtRect3.y , 285, 25, 0xFFFFFF); SDL_Flip(screen); } if(event3.key.keysym.sym == 0x0D) /*если нажат Enter*/ { if(txtRect3.y == men1) /*Играть*/ { igra.Game(screen); return 0; } if(txtRect3.y == men2) /*Смена игрока*/ { while(name[i3]!='\0') name[i3++] = '\0'; Zastavka2(screen); return 0; } if(txtRect3.y == men3) /*Просмотр результатов*/ { Tablitca(screen); return 0; } if(txtRect3.y == men4) /*Правила игры*/ { PravilaGame(screen); return 0; } if(txtRect3.y == men5) /*Выход*/ end3 = 1; } } } } } return end3; }