当前位置: 首页>>代码示例>>C++>>正文


C++ MyDialog::Start方法代码示例

本文整理汇总了C++中MyDialog::Start方法的典型用法代码示例。如果您正苦于以下问题:C++ MyDialog::Start方法的具体用法?C++ MyDialog::Start怎么用?C++ MyDialog::Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyDialog的用法示例。


在下文中一共展示了MyDialog::Start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {
   ALLEGRO_DISPLAY     *display;
   ALLEGRO_TIMER       *tick_timer;

   if (!al_init()) {
      TRACE("Allegro init failed!\n");
      return 1;
   }

   al_init_font_addon();
   al_init_image_addon();
   al_init_primitives_addon();
   al_install_keyboard();
   al_install_mouse();

   display = al_create_display(640, 480);
   if (!display) {
      TRACE("Display init failed!\n");
      return 1;
   }

   al_hide_mouse_cursor(display);

   /* Must set this before calling InstallMASkinG() ! */
   MAS::SetLogicRate(1.0 / 0.02);

   /* MASkinG must be initialized after the display. */
   if (InstallMASkinG("allegro.cfg") != MAS::Error::NONE ) {
      TRACE("MA5kinG init failed!\n");
      return 1;
   }

   tick_timer = al_create_timer(0.02);

   queue = al_create_event_queue();
   al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) al_get_keyboard_event_source());
   al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) al_get_mouse_event_source());
   al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) display);
   al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) tick_timer);

   // create a new dialog on the current display
   MyDialog *dlg = new MyDialog();

   al_start_timer(tick_timer);

   /* You have to call this manually. */
   dlg->Start();

   while (!dlg->ShouldClose()) {
      ALLEGRO_EVENT event;
      al_wait_for_event(queue, &event);

      switch (event.type) {
         case ALLEGRO_EVENT_TIMER:
            if (event.timer.source == tick_timer) {
               dlg->DoTick();

               /* Skip the drawing if we've got more events to process. */
               if (!al_event_queue_is_empty(queue))
                  continue;

               /* Redraw the screen */
               al_clear_to_color(al_map_rgb(0, 0, 0));
               dlg->Draw();
               al_flip_display();
            }
            else
               /* Oh, it must be the game timer. */
               dlg->ProcessEvent(&event);
         break;
         default:
            dlg->ProcessEvent(&event);
      }
   }

   /* You have to call this manually. */
   dlg->End();

   // delete the dialog
   delete dlg;

   ExitMASkinG();

   return 0;
}
开发者ID:bambams,项目名称:ma5king,代码行数:85,代码来源:ex05.cpp


注:本文中的MyDialog::Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。