2017-10-11 88 views
-1

我已经开始致力于构建PacMan游戏的C项目,但在执行下面的代码时出现错误。该错误由Code :: Blocks和Turbo C++ 3.5生成。 在Code :: Blocks中,我删除了"C:\TurboC3\BGI"的路径,但错误仍然存​​在。将不胜感激。不能将颜色包含到我的C文件中

谢谢!

错误在Turbo C++ Turbo C++ error

错误代码::块 Error in Code::Blocks

#include<stdio.h> 
#include<conio.h> 
#include<graphics.h> 
int main() 
{ 
    int gd=0,gm; 
    initgraph(&gd,&gm,"C:\\TurboC3\\BGI"); 
    setfillpattern(SOLID_FILL,YELLOW); 
    circle(200,100,10); 
    line(200,250,200,250); 
    line(225,250,225,250); 
    line(250,250,250,250); 
    line(275,250,275,250); 
    line(300,250,300,250); 
    line(325,250,325,250); 
    arc(50,225,110,-100,30); 
    printf("Hello...Let's Play PacMan !! \n\n"); 
    getch(); 
    closegraph(); 
    return 0; 
} 
+2

后你所得到的错误。 –

+8

Turbo C++? BGI?我想你应该看看日历。它错误的千年。 –

+0

我已添加错误图像@JohnnyMopp现在可以引用它们。 –

回答

3

我不使用BGI,但快速搜索发现setfillpattern期待一个char数组作为第一个参数,但SOLID_FILL的类型为enum fill_styles。要使用SOLID_FILL,您需要改为拨打setfillstyle

要使用setfillpattern您需要提供一个自定义模式:

char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x24, 0x24, 0x07, 0x00}; 
setfillpattern(pattern, YELLOW); 
+0

非常感谢你@JohnnyMopp,它真的帮了很多。 –