Original Post
Ok, I am creating a game for my History Project. The project is due tommorow, and I have been working non-stop for a week, to get this project done. You can say that I have been in crunch mode. Anyway, today I fixed a collision detection issue, so that fixed 3 bugs at the same time. So I go..."YES", but I was wrong. I go to make the Main Menu, and guess what...for some reason it is not working! I would just figure this out by my self, but I only have the rest of tonight to fix this problem, so I had to come here and ask. Here is the problem: The Main Menu flips properly, and it accepts input, but after it accepts the input, it just closes! I have tried all kinds of different techniques to fix this, but none of them have worked. Can y'all help me please? Code: Thanks to all who help! Chad.
void Main_Menu()
{
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER );
TTF_Init();
SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0, SDL_DOUBLEBUF );
SDL_WM_SetCaption(WINDOW_TITLE, 0);
SDL_Event event;
while(menurunning)
{
printf("Now in the Main Menu");
DrawText("(P)lay Game", 24, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 255, 255, 255, 0, 0, 0);
DrawText("(I)nformation About Game", 24, WINDOW_WIDTH/2, WINDOW_HEIGHT/2+30, 255, 255, 255, 0, 0, 0);
DrawText("(E)xit Game", 24, WINDOW_WIDTH/2, WINDOW_HEIGHT/2+60, 255, 255, 255, 0, 0, 0);
while(SDL_PollEvent(&event))
{
if(event.type==SDL_QUIT)
{
gamerunning=false;
}
}
if(event.type==SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_p: Init_Game(); break;
case SDLK_i: Information(); break;
case SDLK_e: SDL_Quit(); break;
}
}
SDL_Flip(SDL_GetVideoSurface());
}
}