日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

c语言编译kbhit出现问题,在VC++中运行出现error C2065: 'kbhit' : undeclared identifier,什么意思?怎么调试?...

發布時間:2024/3/13 c/c++ 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言编译kbhit出现问题,在VC++中运行出现error C2065: 'kbhit' : undeclared identifier,什么意思?怎么调试?... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在VC++中運行出現error?C2065:?'kbhit'?:?undeclared?identifier,什么意思?怎么調試?0

yareate2013.04.08瀏覽493次分享舉報

#define N 200

#include

#include

#include

#define LEFT 0x4b00

#define RIGHT 0x4d00

#define DOWN 0x5000

#define UP 0x4800

#define ESC 0x011b

int i,key;

int gamespeed=60000;/*游戲速度自己調整*/

struct car

{

int x[N];

int y[N];

int node;/*小車的節數*/

int direction;/*小車移動方向*/

}car;

void Init(void);/*圖形驅動*/

void Close(void);/*圖形結束*/

void DrawK(void);/*開始畫面*/

void GameOver(void);/*結束*/

void GamePlay(void);/*具體過程*/

/*主函數*/

void main(void)

{

Init();/*圖形驅動*/

DrawK();/*開始畫面*/

GamePlay();/*具體過程*/

Close();/*圖形結束*/

}

/*圖形驅動*/

void Init(void)

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"c:\\tc");

cleardevice();

}

/*開始畫面,左上角坐標為(50,40),右下角坐標為(610,460)的圍墻*/

void DrawK(void)

{

setbkcolor(BLUE);

setcolor(11);

setlinestyle(SOLID_LINE,0,THICK_WIDTH);/*設置線型*/

for(i=50;i<=600;i+=10)/*畫圍墻*/

{

rectangle(i,40,i+10,49); /*上邊*/

rectangle(i,451,i+10,460);/*下邊*/

}

for(i=40;i<=450;i+=10)

{

rectangle(50,i,59,i+10); /*左邊*/

rectangle(601,i,610,i+10);/*右邊*/

}

}

void GamePlay(void)

{

car.direction=1;/*方向往右*/

car.x[0]=100;car.y[0]=100;/*車頭*/

car.x[1]=110;car.y[1]=100;

car.node=4;/*節數*/

while(1){

while(!kbhit())/*在沒有按鍵的情況下,小車自己移動身體*/

{for(i=car.node-1;i>0;i--)/*小車的每個環節往前移動,也就是小車運行的關鍵算法*/

{car.x[i]= car.x[i-1];

car.y[i]=car.y[i-1];}

/*1,2,3,4表示右,左,上,下四個方向,通過這個判斷來移動車頭*/

switch(car.direction)

{

case 1:car.x[0]+=20;break;

case 2: car.x[0]-=20;break;

case 3: car.y[0]-=20;break;

case 4: car.y[0]+=20;break;

}

if(car.x[0]<55||car.x[0]>595||car.y[0]<65||

car.y[0]>455)/*小車是否撞到墻壁*/

{GameOver();/*本次演示結束*/

getch();}

setcolor(4);/*畫出小車*/

for(i=0;i

rectangle(car.x[i],car.y[i],car.x[i]+20,

car.y[i]-20);

delay(gamespeed);

setcolor(BLUE);/*用背景色去除車的的最后一節*/

rectangle(car.x[car.node-1],car.y[car.node-1],

car.x[car.node-1]+20,car.y[car.node-1]-20);

/*endwhile(!kbhit)*/

}

key=bioskey(0);/*接收按鍵*/

if(key==ESC)/*按ESC鍵退出*/

GameOver();

else

if(key==UP&&car.direction!=4)

/*判斷是否往相反的方向移動*/

car.direction=3;

else

if(key==RIGHT&&car.direction!=2)

car.direction=1;

else

if(key==LEFT&&car.direction!=1)

car.direction=2;

else

if(key==DOWN&&car.direction!=3)

car.direction=4;

}/*endwhile(1)*/

}

void GameOver(void)

{ cleardevice();

setcolor(RED);

settextstyle(0,0,4);

outtextxy(200,200,"GAME OVER");

Close();

}

/*圖形結束*/

void Close(void)

{

getch();

closegraph();

}

總結

以上是生活随笔為你收集整理的c语言编译kbhit出现问题,在VC++中运行出现error C2065: 'kbhit' : undeclared identifier,什么意思?怎么调试?...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。