示例#1
0
        public bool process()
        {
            // Input
            SDL.SDL_Event e;
            while (SDL.SDL_PollEvent(out e) != 0)
            {
                switch (e.type)
                {
                case SDL.SDL_EventType.SDL_QUIT:
                    // Release all textures
                    SDL.SDL_DestroyTexture(title);
                    foreach (IntPtr tex in options)
                    {
                        SDL.SDL_DestroyTexture(tex);
                    }

                    // Shut down the engine and quit the game
                    Engine.HandleQuit();
                    break;

                case SDL.SDL_EventType.SDL_KEYDOWN:
                    // Figure out which key
                    switch (e.key.keysym.sym)
                    {
                    case SDL.SDL_Keycode.SDLK_DOWN:
                        // Go down an option
                        selected++;
                        if (selected >= options.Count)
                        {
                            selected--;
                        }
                        break;

                    case SDL.SDL_Keycode.SDLK_UP:
                        // Go up an option
                        selected--;
                        if (selected < 0)
                        {
                            selected = 0;
                        }
                        break;

                    case SDL.SDL_Keycode.SDLK_RETURN:
                        // Run the event
                        return(HandleOptionEvent.Invoke(selected));
                    }
                    break;
                }
            }

            return(true);
        }