VC++ C++ C# Algorithm

C++博客 首页 新随笔 联系 聚合 管理
  21 Posts :: 3 Stories :: 31 Comments :: 0 Trackbacks


事件驱动已经不是什么新名词了,事件可以是按下一个键,鼠标移动,改变窗口尺寸和点击关闭按钮。这次我们学习如何处理在SDL进行事件驱动编程。

实际上在SDL进行事件驱动编程很简单,为什么?看看代码就知道了哦。

int  main(  int  argc,  char *  args[] )
{
    SDL_Event 
event
;
//
一个SDL_Event结构体用于存储所发生事件的相关信息,以便我们可以处理它
    
// Make sure the program waits for a quit

     bool  quit  =   false ;
    
while ( quit  ==   false
 )
    
{
        
while ( SDL_PollEvent(  & event
 ) )
        
{
            
// If the user has Xed out the window

             if event .type  ==  SDL_QUIT )
            
{
                
// Quit the program

                quit  =   true ;
            }
    
        }

    }

}
怎么了,结束了,就这么简单。
posted on 2007-03-07 23:03 大熊猫 阅读(524) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理