【问题标题】:I can't log out the output C program我无法注销输出 C 程序
【发布时间】:2017-07-29 10:56:41
【问题描述】:

我正在使用 allegro 库开发游戏。我写了一个起始 C 代码然后我在 Ubuntu 终端上编译程序。之后当我打开输出程序时,程序打开但没有关闭。取消按钮(X)不起作用。

这是我的入门代码:

#include <allegro.h>

void Baslat();
void Bitir();

int main(){
        Baslat();
        while(!key[KEY_ESC]){

        }
        Bitir();
        return 0;
}

END_OF_MAIN()

void Baslat(){
        int depth,res;
        allegro_init();
        depth = desktop_color_depth();
        if(depth == 0) depth=32;
        set_color_depth(depth);
        res=set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480,0,0);
        if(res!=0){
                allegro_message("%s\n", allegro_error);                  exit(-1);
        }
        install_timer();
        install_keyboard();
        install_mouse();

}


void Bitir(){
  clear_keybuf();

}

【问题讨论】:

  • 尝试调试?在调试器中运行您的应用程序,并在退出时按 Ctrl+C。
  • 我根据标签回答了allegro5,但看起来您实际上是在使用allegro4。您对哪个版本的 allegro 感兴趣?

标签: c allegro allegro5


【解决方案1】:

要响应用户在 allegro5 中按下X 按钮,您必须捕获ALLEGRO_EVENT_DISPLAY_CLOSEThis tutorial 提供了响应该事件的示例。

【讨论】:

  • 是的,我使用 allegro4,但我无法理解您的回答。我应该使用哪个快板版本?有没有办法解决我在 allegro4 的问题?
  • 使用哪个版本是个人决定,但我会使用最新版本,除非您有令人信服的理由使用旧版本。我不使用allegro4,所以我不知道如何解决您的问题。如果您使用的是allegro5,我链接的教程会提供代码示例和解释,说明您想要什么。
猜你喜欢
  • 2016-09-03
  • 2018-03-22
  • 2011-08-28
  • 1970-01-01
  • 2019-09-20
  • 1970-01-01
  • 2021-06-15
  • 2014-08-01
  • 1970-01-01
相关资源
最近更新 更多