/*Troy Rosin*/ #include #include extern int running; void handle_input_mainmenu(SDL_Event *e); void handle_input_battle(SDL_Event *e); void handle_event(SDL_Event *e){ while(SDL_PollEvent(e)) { switch(state) { case TITLE: if(e->type == SDL_KEYDOWN) { handle_input_mainmenu(e); } break; case BATTLE: switch (e->type) { case SDL_KEYDOWN: handle_input_battle(e); break; case SDL_MOUSEBUTTONDOWN: dragging = GRAB_NEW; break; case SDL_MOUSEBUTTONUP: dragging = LETGO; } break; } return; } } void handle_input_mainmenu(SDL_Event *e) { switch(e->key.keysym.sym){ case SDLK_ESCAPE: running = 0; break; case SDLK_w: if (selected_index) { selected_index--; } else { selected_index = MAIN_SELECTIONS - 1; } selected_index %= MAIN_SELECTIONS; break; case SDLK_s: selected_index++; selected_index %= MAIN_SELECTIONS; break; case SDLK_RETURN: if(selected_index == EXIT_GAME){ running = 0; } else{ state = BATTLE; } } return; } void handle_input_battle(SDL_Event *e) { switch(e->key.keysym.sym) { case SDLK_ESCAPE: running = 0; break; default: printf("%d", (char)e->key.keysym.sym); } return; }